Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //transmitter code (software)
- #include <SoftwareSerial.h>
- SoftwareSerial gtSerial(2, 3); // Arduino RX, Arduino TX
- void setup()
- {
- Serial.begin(9600); // serial / USB port
- gtSerial.begin(9600); // software serial port
- }
- byte rx_byte = 1; // byte used to transmit 1 byte of code of '1'
- void loop()
- {
- gtSerial.write(rx_byte);
- Serial.println(rx_byte); //though redundant, checks value
- }
- //receiver code (software)
- #include <SoftwareSerial.h>
- SoftwareSerial gtSerial(2, 3); // Arduino RX, Arduino TX
- int LED = 6; //LED on Arduino board
- void setup()
- {
- pinMode(LED, OUTPUT);
- Serial.begin(9600); // serial / USB port
- gtSerial.begin(9600); // software serial port
- }
- byte rx_byte = 0; // stores received byte
- void loop()
- {
- rx_byte = gtSerial.read();
- Serial.println(rx_byte);
- (rx_byte==1)?(digitalWrite(LED, HIGH)):(digitalWrite(LED, LOW))//desired output
- }
Add Comment
Please, Sign In to add comment