السلام عليكم
تم كتابة هذا الكود ولكن السفن سكمن واقف اصفار فقط لايتغير
هو مقياس تيار بالحساس ACS712 والبك المستخدم 16F677
كود:
long u0; long u1; long u2;
unsigned long temp=0;
unsigned long seg[]={64,121,36,48,25,18,2,120,0,16};
void s7 ()
{
u0=(temp%10);
u1=((temp%100)/10);
u2=(temp%1000)/100;
PORTB=32;PORTC=seg[u0];Delay_ms(4);
PORTB=64;PORTC=seg[u1];Delay_ms(4);
PORTB=128;PORTC=seg[u2];Delay_ms(4); }
char message[] = "ACS712-05 Sensor";
unsigned int ADC_Value, Factor;
void main( )
{
TRISA=0b00000111;
TRISB=0b00010000; TRISC=0; PORTC=0; portb=0;
while(1)
{ ADC_Value = ADC_Read(0);
ADC_Value = ADC_Value + ADC_Read(0);
ADC_Value = ADC_Value + ADC_Read(0);
ADC_Value = ADC_Value/3;
temp = (ADC_Value-512)*Factor ;
ADC_Value = temp/10;
s7 (); Delay_ms(10); }}