Pages: [1]   Go Down
Author Topic: Serial.print problem  (Read 284 times)
0 Members and 1 Guest are viewing this topic.
London
Offline Offline
Full Member
***
Karma: 0
Posts: 192
Yes, we can (solder)!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been trying to interface a Duemilanove with Processing, Max/MSP and Pure Data and read an analog input. I've done this dozens of times with no problem yet this time I don't get the values I'm expecting. Whichever software the board is interfaced, I only useless, get two-digit values instead of the 0-1024. I get the correct values in the Arduino serial monitor but only there. I tried different baud rates, installed the latest FTDI driver, tried hex and decimal encoding with no success. I haven't tried the Firmata. This is the code:


void setup() {
  Serial.begin(9600);
}
void loop() {
  int val = analogRead(0);
  Serial.print(val,DEC)
  delay(50);
}


Any ideas?
Logged

London
Offline Offline
Full Member
***
Karma: 0
Posts: 192
Yes, we can (solder)!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess the serial values are sent as ASCII characters since I get two-digit values around 50. How can I get around this problem?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 553
Posts: 46281
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I guess the serial values are sent as ASCII characters since I get two-digit values around 50.
They are, if you use Serial.print().

Quote
How can I get around this problem?
What problem? If the "problem" is that the data is being sent as ASCII data, then stop doing that. Use Serial.write() instead. Keep in mind, though, that Serial.write() only sends bytes, not ints.
Logged

Pages: [1]   Go Up
Jump to: