[PD] puredata to arduino

Hi, I'm trying to control the Arduino digital out from PureData. I'm using comport in PD to send serial data over the port and I need Arduino to read it and excecute a task. This seems like a realy simple thing to do, but I can't get it to work. I'm using the Serial Read Advanced example included int the Arduino 003. The TX light turns on in the board when sending data over the port, but no luck with the LED...

Any help would be very apreciated,

Thanks, adrián goya

int ledPin = 13; // LED en el pin 13 int val = 0; //variabe para guardar el data del puerto serial int serbyte = 0; //variable para guardar el data VALIDO del puerto

void setup() {

pinMode(ledPin, OUTPUT); beginSerial(19200); }

void loop() { serbyte = serialRead(); if (val != -1) { val = serbyte; }

if (val == 113) { digitalWrite(ledPin, LOW); } else { digitalWrite(ledPin, HIGH); delay(1000); }


Whoops, looks like a bug in that example. Thanks for finding it.

This code:

if (val != -1) { val = serbyte; }

should be:

if (serbyte != -1) { val = serbyte; }

Thank you mellis for the response. I corrected the error you pointed out but it didn't completely fix it.

I also changed the variable declaration in the beginning:

int val = 0; int serbyte = 0;


char val = 0; char serbyte = 0;

and now it seems to be working fine.

adrian goya.

note: same story for the Serial Read Basic example.

Thanks for your patience and posting the corrections (and in Spanish too!). It's been added to the bug database and should be fixed in the next release.