#include #include /* required for delay function */ #define DATA 0x0378 #define STATUS DATA+1 #define CONTROL DATA+2 void out_port(unsigned char value) { outportb(DATA,value); } unsigned char in_port(void) { unsigned char in_s; { outportb(CONTROL,0x04); delay(1); outportb(CONTROL,0x00); // שליחת 0 לוגי לממיר להתחלת המרה delay(1); outportb(CONTROL,0x04); delay(10); outportb(CONTROL,0x06); // 74LS244 1G שליחת בקרה לרגל delay(1); in_s =(( inportb(STATUS)&0xF0)^0x80)>>4; //A/D ADC0804 קליטת 4 סיביות עליונות delay(1); outportb(CONTROL,0x05); //74LS244 2G שליחת בקרה לרגל delay(1); in_s=((inportb(STATUS)&0xF0)^0x80)|in_s; //A/D ADC0804 קליטת 4 סיביות תחתונות outportb(CONTROL,0x04); return in_s; } } void main(void) { int in; while(1) { in=in_port(); printf("the value is %d\n",in); if(in<50) out_port(0x07); else if(in<100) out_port(0x03); else if(in<150) out_port(0x01); else out_port(0); delay(1000); } }