Reply To: Serial won't work
About › Forums › Forum › Breakout Beta Issues › Serial won't work › Reply To: Serial won't work
Yes I use baud rate 9600. Right now I am testing with two Arduinos: One running BreakoutFirmata and the other running this sketch:
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there’s incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it’s a capital H (ASCII 72), turn on the LED:
if (incomingByte == ‘H’) {
digitalWrite(ledPin, HIGH);
Serial.write(“We turn ON”);
}
// if it’s an L (ASCII 76) turn off the LED:
if (incomingByte == ‘L’) {
digitalWrite(ledPin, LOW);
Serial.write(“We turn OFF”);
}
}
}
I have connected the Arduinos like this: http://robotic-controls.com/sites/default/files/learn/Arduino-ArduinoSerial.png
In your serialWrite-example, I use hardware serial like this:
serial = new Serial({
board: arduino,
port: Serial.HW_SERIAL1,
baud: 9600
});
When I only use the Arduino with the above sketch and just write to it in the Arduino IDE serial monitor, it works – I can toggle the LED. But when I connect the two Arduinos and write via the serialWrite-example, it still doesn’t work.