ArduinoGeneral

Wireless programming modules and Processing

userHead DebianAddict 2014-03-04 00:05:20 1820 Views1 Replies
Hello,
I am using a Processing interface to control a robot that I am making. I ordered the DFRobot wireless programming kit for arduino ([url=http://www.dfrobot.com/index.php?route=product/product&filter_name=wireless%20programming%20modules&product_id=409#.UxSjEIUXdvh]http://www.dfrobot.com/index.php?route=product/product&filter_name=wireless%20programming%20modules&product_id=409#.UxSjEIUXdvh[/url]) and I went through configuring the modules successfully. I was able to upload code with the units directly from the arduino IDE successfully as well. I then went to test bringing processing into the mix with a simple program that I could debug easily. I uploaded this code onto the arduino board:

[code]char val; // Data received from the serial port
int ledPin = 13; // Set the pin to digital I/O 13

void setup() {
pinMode(ledPin, OUTPUT); // Set pin as OUTPUT
Serial.begin(38400); // Start serial communication at 9600 bps
}

void loop() {
if (Serial.available())
{ // If data is available to read,
val = Serial.read(); // read it and store it in val
}
if (val == '1')
{ // If 1 was received
digitalWrite(ledPin, HIGH); // turn the LED on
} else {
digitalWrite(ledPin, LOW); // otherwise turn it off
}
delay(10); // Wait 10 milliseconds for next reading
}[/code]

and then I started to run this processing sketch:

[code]import processing.serial.*;

Serial myPort; // Create object from Serial class

void setup()
{
size(200,200); //make our canvas 200 x 200 pixels big
myPort = new Serial(this, "COM5", 38400);
}

void draw() {
if (mousePressed == true)
{ //if we clicked in the window
myPort.write('1'); //send a 1
println("1");
} else
{ //otherwise
myPort.write('0');
println("0"); //send a 0
}
}[/code]
This works just fine over a hard wired serial bus, but when this is done over the wireless module, the LINK light stays on when the processing sketch is running and nothing happens. Can anyone tell me what I need to do to my code or my hardware to make this work.
Thanks,
DebianAddict
2014-03-04 15:58:38 Hello,
I guess the problem caused by the baud rate.
It is better to use the same baud rat (sketch 1 and two WPM modules).
userHeadPic Grey.CC