I am using an HC-12 Bluetooth to communicate between two Arduinos in order to to push a button on one Arduino in order to turn on an LED on another Arduino. The problem is the light is not turning on and I am not receiving messages between my serial monitors. I am pretty sure my wiring is correct, so I think it is my code. I have attached pictures of my circuit just in case.
Sender Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //RX, TX
int buttonPin = 8;
void setup() {
pinMode(buttonPin, INPUT);
mySerial.begin(9600);
}
void loop() {
int buttonState = digitalRead(buttonPin);
if(buttonState == 1){//if button is down
mySerial.println(1234);//send unique code to the receiver in this case 1234
}
delay(20);//delay little for better serial communication
}
Receiver Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //RX, TX
int buttonPin = 8;
void setup() {
pinMode(buttonPin, INPUT);
mySerial.begin(9600);
}
void loop() {
int buttonState = digitalRead(buttonPin);
if(buttonState == 1){//if button is down
mySerial.println(1234);//send unique code to the receiver in this case 1234
}
delay(20);//delay little for better serial communication
}