Hey guys,
I'm currently working on my project and need this little test element to work. I want to send and receive data from an Arduino to PC using a HC-06. That's why I want to start little and have come across this tutorial on youtube (link in the code), followed the instruction and I could control the LED by typing 1 or 0 into the serial monitor.
The problem is that I won't receive any prints. I won't receive any softSerial.println although I can clearly control the LED. Therefore, the prints should occur in the serial monitor like in the video, right? But it just keeps being blank and I also don't receive any errors, so... I don't know.
Since the serial monitor settings are being covered by the cam, I assume that the baudrate is 38400 and CR&NL is on.
//code write by Moz for YouTube changel LogMaker360, 27-10-2015
//code belongs to this video: https://www.youtube.com/watch?v=6jZMJ7DFCY0
#include <SoftwareSerial.h>
SoftwareSerial softSerial(10, 11); //RX/TX
void setup()
{
// set digital pin to control as an output
pinMode(LED_BUILTIN, OUTPUT);
// set the data rate for the SoftwareSerial port
softSerial.begin(38400);
// Send test message to other device
softSerial.println("Hello from Arduino");
}
char a; // stores incoming character from other device
void loop() {
if (softSerial.available())
// if text arrived in from softSerial...
{
a=(softSerial.read());
softSerial.println(a);
if (a=='1')
{
digitalWrite(LED_BUILTIN, HIGH);
softSerial.println(" LED on"); //does not print
}
if (a=='0')
{
digitalWrite(LED_BUILTIN, LOW);
softSerial.println(" LED off"); //does not print
}
if (a=='?')
{
softSerial.println("Send '1' to turn LED on");
softSerial.println("Send '0' to turn LED off");
}
// you can add more "if" statements with other characters to add more commands
}
}
I hope you can help me. If you need further information, just ask ![]()