if I change with this one
on arduino:
int inbyte = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
inbyte = Serial.read();
if(inbyte=='0'){
Serial.print(analogRead(0));
delay(10);
Serial.print(" ");
delay(10); }
if(inbyte=='1'){
Serial.print(analogRead(1));
delay(10);
Serial.print(" ");
delay(10);}
}
on C:
while(1){
open_port();
write(fd,"0",1);
read(fd,buf0,10);
printf(" %s \n",buf0);
usleep(100);
write(fd,"1",1);
read(fd,buf1,10);
printf(" %s \n",buf1);
usleep(100);
}
There are no result on C, but when I open the serial port monitor on arduino. The results appear on the C program.
but the result is weird.
I Put 0 in input 0 and put 5 v (1023) in input 1.
in serial monitor appear 102 0
in c appears
3
(empty)
sometimes
in serial monitor 10 0
in c appears
23
(emty)