I have a problem with the physicalpixel example sketch, mainly that I don't seem to be able to make it work.
I have a Duemilanove board with 328. When I type 'H' or 'L' from the serial monitor, nothing happens.
I have tested that I can turn the led on, I have tested that I can read serial produced from the arduino, but nothing I have tried seems to make the led turn on via serial.
I only didn't post the code because it's just a standard example, but here it is. Thanks
/*
Physical Pixel
An example of using the Arduino board to receive data from the
computer. In this case, the Arduino boards turns on an LED when
it receives the character 'H', and turns off the LED when it
receives the character 'L'.
The data can be sent from the Arduino serial monitor, or another
program like Processing (see code below), Flash (via a serial-net
proxy), PD, or Max/MSP.
The circuit:
* LED connected from digital pin 13 to ground
created 2006
by David A. Mellis
modified 14 Apr 2009
by Tom Igoe and Scott Fitzgerald
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/PhysicalPixel
*/
//const int ledPin = 8; // the pin that the LED is attached to
int val; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(8, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
// see if there's incoming serial data:
if (Serial.available()) {
// read the oldest byte in the serial buffer:
val = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED:
if (val == 'H') {
digitalWrite(8, HIGH);
}
// if it's an L (ASCII 76) turn off the LED:
if (val == 'L') {
digitalWrite(8, LOW);
Serial.print('H');
delay(1000);
Serial.print('L');
delay(1000);
}
}
}
I still have not managed to make this work, however I can update with some strange behaviour.
I minimised the code to this:
int incomingByte; // a variable to read incoming serial data into
void setup() {
Serial.begin(9600);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
Serial.print('L');
}
}
This does not produce anything at all to the serial monitor. So I tried this:
This does print a continuous line of 'L's' to the serial monitor. So I seem to be having an issue with the "if (Serial.available() > 0)" line of code, I have tried changing the 0 to other numbers, but this makes no difference.
When I try either of the codes I can see that the RX led on the Arduino flickers, so I guess serial data must be getting to the board.
Please can someone help. This seems such a silly thing to be stuck on. I must be missing something.
I am using an Arduino, plugged in via USB, with no other hardware, I have tried two different PC's, just in case there was something wrong with one of them.
When I try either of the codes I can see that the RX led on the Arduino flickers, so I guess serial data must be getting to the board.
Either of the two codes in your last reply, or any of the codes you've posted so far?
The RX light should flash when the Arduino receives data. The TX light should flash when the Arduino sends data.
You haven't mentioned what operating system you are using. That might be relevant. Although, if you are able to upload code to the board, it means that the PC CAN talk to the Arduino.
The RX led flashes with any of the codes, it also flashes when I upload, so yes the PC can talk to the board.
I have tried this on windows 7 starter and also windows 7 pro 64bit.
I have tried various examples that are included with the IDE, I can read serial from the arduino, but don't seem to be able to send to it. I ran the example called SerialCallResponseASCII, I could recieve the data being sent, but don't get a response when I send anything.
I have tried various examples that are included with the IDE, I can read serial from the arduino, but don't seem to be able to send to it. I ran the example called SerialCallResponseASCII, I could recieve the data being sent, but don't get a response when I send anything.
I have no clue what is wrong, then. The Arduino IDE is clearly able to send data to the Arduino.