Serial.print prints random 255


hey,
i working on mac app control arduino , works if send values 0-63 arduino using following code on arduino:
code: [select]
void setup() {
 serial.begin(2000000);
 serial.print("\n\nhello, rebooted\n\n");
}

void loop() {
 uint8_t incomingbyte[2];
 // send data when receive data:
 if (serial.available() > 0) {

   for (int = 0; < 2; i+=2){
     // read incoming byte:
     incomingbyte[i] = serial.read();
     incomingbyte[i+1] = serial.read();
   }
   serial.println(incomingbyte[0], dec);
   serial.println(incomingbyte[1], dec);
   delaymicroseconds(5000);
 }
}


the print out should read 0-63 reads is:
0
255
1
2
3
4
...
62
63
255

the shorter delay put in more 255 appear. idea on happening?

thanks
-korki

why have baud rate @ 2000000?

try setting 9600 , see happens....


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Serial.print prints random 255


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums