I'm trying to send data from Arduino Mega to UNO.
The master code sends characters 'x' and 'a' every half second to the slave Arduino UNO.
Slave receives the characters and switches the state of the onboard LED.
Here I'm trying to print some text in the beginning of the loop and the characters received.
Instead of the letters it is printing numbers as given below.
Why this line Serial.println('Soft serial avaialble')
prints numbers?
How to print real text received from the master?
> 27749
> 97
> 27749
> 120
> 27749
Master code:
// Include the Software Serial library
#include <SoftwareSerial.h>
// Define a Software Serial object and the used pins
SoftwareSerial softSerial(8, 9); // RX, TX
void setup() {
Serial.begin(9600);
softSerial.begin(9600);
}
void loop() {
// Sends characters 'x' and 'a' every half second.
if (Serial.available()) {
softSerial.write('x');
delay(500);
digitalWrite(LED, LOW);
delay(500);
}
}
Slave code:
// Include the Software Serial library
#include <SoftwareSerial.h>
// Define a Software Serial object and the used pins
SoftwareSerial softSerial(8, 9);
// LED Pin
int LED = 13;
void setup() {
softSerial.begin(9600);
Serial.begin(9600);
pinMode(LED, OUTPUT);
}
void loop() {
Serial.println('Soft serial avaialble');
if (softSerial.available()) {
int com = softSerial.read();
if (com == 'x') {
Serial.println(com);
digitalWrite(LED, LOW);
} else if (com == 'a'){
Serial.println(com);
digitalWrite(LED, HIGH);
}
}
}