I have a transmitter and receiver sending signals to each other based on what the number the transmitter sends i want the lcd to print a different message. I want "0" to mean "Hi" and "1" to mean "O.O". I am worried about the way i'm writing it, any advice? I've tried writing it with a switch case, but it wasn't working.
LiquidCrystal lcd(12, 8, 5, 4, 3, 2);
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message
const int threshold = 1;
int sensorReading= 0;
int sensorPin = 11; //Try 11
void setup()
{
Serial.begin(9600);
Serial.println("Device is ready");
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver
lcd.begin(16, 2);
// Print a message to the LCD.
}
void loop()
{
if (vw_get_message(message, &messageLength)) // Non-blocking
{int sensorReading = analogRead(sensorPin); //try digitalRead w/d11 or analogRead A0
if (sensorReading = threshold){
lcd.setCursor(0, 1);
lcd.print("O.O");
delay(1);
}
if (sensorReading = sensorReading){
lcd.setCursor(0, 1);
lcd.print("Hi!");
delay(1);
}
}
{
Serial.print("Received: ");
for (int i = 0; i < messageLength; i++)
{
Serial.write(message[i]);
}
Serial.println();
}}