Pages: [1]   Go Down
Author Topic: Serial and Processing  (Read 597 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a pot hooked up to my Arduino sending the value over serial to my computer. In the Arduino serial monitor the values come back the way they are supposed to, but when I do serial.read() in processing the values jump between random values, even when Im not moving the pot. Even when I do move the pot it still jumps between the same random values. Am I doing something wrong in processing? I basically have it set up like val=port.read(); println(val); If anyone has any ideas to what Im doing wrong, let me know. Thanks.
Logged

London
Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you had a look at this potentiometer + arduino + processing tutorial?
http://webzone.k3.mah.se/projects/arduino-workshop/projects/arduino_meets_processing/instructions/poti.html

The framerate() function was renamed frameRate() recently.  Other than that the downloadable code should still work.
« Last Edit: November 09, 2006, 01:40:13 pm by neillzero » Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the problem is that you're sending from Arduino a string of digits - e.g. 123 would be sent as the three bytes '1', '2', '3' (which have ASCII values of 49, 50, and 51) - but reading in Processing only a byte at a time.  What you need to do is read the incoming bytes as characters in Processing, collect them until you reach a newline or carriage return and then convert the accumulated string to an integer.  The link neillzero mentioned has some code for this.
Logged

Pages: [1]   Go Up
Jump to: