Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
riccardo.ancona
riccardo.ancona's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Processing serial output vs Arduino serial input
[0 Replies]
26-Mar-2011 06:07 PM
Forum:
Integration and Hardware
Hi folks!
I have to send via serial port an integer to an Arduino board using a baud rate of 9600.
The problem is that if I send this integer simply as a "int" using this code:
int message = 4000;
Serial.write(a);
delay(5)
arduino will receive one number that is not the one I sent!!!
If I just split the integer into 4 byte and send them one after the other, using this code:
int message =4000;
byte sms = byte((message >> 24) & 0x00FF);
myPort.write(sms);
delay(5);
sms = byte((message >> 16) & 0x0FF);
myPort.write(sms);
delay(5);
sms = byte((message >> 8) & 0x00FF);
myPort.write(sms);
delay(5);
sms = byte(message & 0x00FF);
myPort.write(sms);
delay(5);
at the beginning the numbers arrive correctly, but after a while the input arrives messed up.
Anyone knows if there are problem about sending integers in processing?
Thanks you for your time.
Richard
«Prev
Next »
Moderate user : riccardo.ancona
Forum