Hi All,
I am very new to Arduino UNO board and its programming.
what i need to is
- If 0x01 is received on serial port then make Pin13 high and then low.Below is the code for the same:
void setup() {
// put your setup code here, to run once:
Serial.begin(19200);
pinMode(LED_BUILTIN, OUTPUT);
Serial.flush();
}
void loop() {
/* check if data has been sent from the computer: /
if (Serial.available() > 0) {
/ read the most recent byte */
byte byteRead [1] ;
byteRead [0] = Serial.read();
switch (byteRead[0])
{
case 0x01:
// Serial.println("Command 1 is received");
digitalWrite(LED_BUILTIN, HIGH);
delay(20);
digitalWrite(LED_BUILTIN, LOW);
break;
}
}
}
What the issues are:
-
I need to connect digital pin 13 to the button pads of IR remote.When i power up the board it sends high signal to my IR remote button pads irrespective of the 0x01 received on the serial port.
-
Also on start up it shows extra 3 or 4 bytes with values 255.From were this data is coming to Rx buffer of board?
3.Also sometimes it misses to send the signal to IR remote even after receiving 0x01 on serial port.
Can you please help me to figure out whats is wrong with this piece of code?
Thanks a lot in advance