hi.. i have a question here. how i'm gonna send hexadecimal value to serial devices. the hex value can be send by using serial write like example below.
//Serial.write(0x55); <----right (HEX)
i wan using hex code to turn the led ....pls help gv an example.....thx
Hex is just a representation. An Arduino doesn't know the difference between '0', 0x30, and 40.
What are these "serial devices"? Are they other Arduinos?
haoyee12:
hi.. i have a question here. how i'm gonna send hexadecimal value to serial devices. the hex value can be send by using serial write like example below.
//Serial.write(0x55); <----right (HEX)
i wan using hex code to turn the led ....pls help gv an example.....thx
1. Build the following network (Fig-1) using UNO and NANO (or UNO and UNO ) to send 0x55 to NANO using soft UART Port.

Figure-1:
2. Upload the following sketch in UNO (untested)
#include<SoftwareSerial.h> //you need to include this file in the IDE
SoftwareSerial SUART(2, 3); //SRX =2, STX = 3 ; this called object creation and intialization
void setup()
{
Serial.begin(9600);
SUART.begin(9600);
}
void loop()
{
SUART.write(0x55); //send 0x55 to NANO
while(1); //wait for ever
}
3. Upload the following sketch in NANO (untested)
#include<SoftwareSerial.h>
SoftwareSerial SUART(2, 3); //SRX =2, STX = 3
void setup()
{
Serial.begin(9600);
SUART.begin(9600);
pinMode(13, OUTPUT); //bulit-in L (LED) of NANO
digitalWrite(13, LOW); //L is OFF
}
void loop()
{
if(SUART.available() >0) //check id a data byte has come from UNO
{
byte x = SUART.read();
if(x == 0x55) //check if the arrived data byte is 0x55
{
digitalWrite(13, HIGH); //L is ON; because, 0x55 has arrived from Transmitter
}
}
}
