۱۶-دى-۱۳۹۱, ۱۵:۰۷:۳۲
سلام.
این برنامه کنترل موتور با ولوم به زبان C :
اینم شبیه ساز:
![[تصویر: Control_Motor_Dc_pic.jpg]](http://s2.picofile.com/file/7609220642/Control_Motor_Dc_pic.jpg)
این برنامه کنترل موتور با ولوم به زبان C :
کد:
#include <mega16.h>
#include <delay.h>
int a;
int b;
unsigned int read_adc(unsigned char adc_input){
ADMUX=adc_input | (0x40 & 0xff);
delay_us(10);
ADCSRA|=0x40;
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;}
void main(){
ADMUX=0x40 & 0xff;
ADCSRA=0x83;
TCCR1A=0xC3;
TCCR1B=0x0A;
DDRB=0xff;
DDRD=0xff;
PIND.6=1;
do{
b=read_adc(0);
OCR1A=b;
a=b;
a=a*0.0097751710654936;
PORTB=a;
}while(1);}
اینم شبیه ساز:
![[تصویر: Control_Motor_Dc_pic.jpg]](http://s2.picofile.com/file/7609220642/Control_Motor_Dc_pic.jpg)