Haberler:

Foruma Resim Yükleme ve Boyut Sınırlaması ( ! )  https://bit.ly/2GMFb8H

Ana Menü

Servo Kontrol

Başlatan handybest06, 19 Mayıs 2012, 08:38:34

handybest06

Servo kontrol için bu kodu kullandım.Ama daha hassas mesela 5-10 dereceye kadar hassas yapamadım.Nasıl yapabilirim.Servo markası towerpro sg90

#include <htc.h>
#include "delay.h" // Gecikme kütüphanesi
__CONFIG(FOSC_HS & WDTE_OFF & BOREN_OFF& PWRTE_ON & BOREN_OFF);
void main(void)
{
char i,karakter=0;
ADCON1=0x07; // PORTA dijital oluyor
PORTB=0x00;
TRISA=0x07; // RA0, RA1 ve RA3 giriG
TRISB=0x00; // PORTB çıkıG
for(;;)
{
if(RA0)
{
for(;;)
{
RB0=1;
// 1ms Gecikme
DelayMs(15);
RB0=0;
// 19ms Gecikme
DelayMs(5);
if(RA1 | RA2)
break;
}}
if(RA1)
{
for(;;)
{
RB0=1;
// 1,5ms Gecikme
DelayUs(250);DelayUs(250);DelayUs(250);DelayUs(250);
DelayUs(250);DelayUs(250);
RB0=0;
// 18,5ms Gecikme
DelayMs(18);
DelayUs(250);DelayUs(250);
if(RA0 | RA2)
break;
}
}
if(RA2)
{
for(;;)
{
RB0=1;
// 2ms Gecikme
DelayMs(2);
RB0=0;
// 18ms gecikme
DelayMs(18);
if(RA0 | RA1)
break;
}
}
}
}