Well depth guage using ultrasonic sensor, rf transmitters, LED display and light

I have two Arduinos, one at the well with the ultrasonic sensor and a transmitter. The other one is inside with a LED display and a receiver. I have everything working fine but I want to add LED lights to be red, yellow, and green depending on water height. I am just starting off with a red light so when the water is really low it will light up but I am getting an error message. I think it is because the transmitter sends the depth as a char and when trying to make the LED light up using that char it doesn't work. The error is (char is not a template)

//load libraries
#include <VirtualWire.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LCD.h>
#define led 11

//Initialise the LCD

LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);
int i; //and integer used to count

void setup()
{
lcd.begin(20,4);
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH);

//Define the receiver pin and rate
vw_set_rx_pin(12); //Sets pin D12 as the RX Pin
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}

void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

if( vw_get_message(buf, &buflen) )
{
lcd.setCursor(0, 0);
lcd.print("Depth is:");
lcd.setCursor(0,1);

for (i = 0; i < buflen; i++)
{
lcd.write(buf*);*

  • }*

  • lcd.print((char)223);*

  • lcd.print("Feet");*

if (char < 17)
{ digitalWrite(led,HIGH);

  • }*
    else {
    digitalWrite(led,LOW);
    }
    }

And now with code tags please.

I will bet that your code did not have italics. Please read the three locked posts at the top of this forum and anything that they link to. Please use autoformat and code tags.

I will bet that you know what transmitter and receiver you have. I don't.

//load libraries
#include <VirtualWire.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LCD.h>
#define led 11

//Initialise the LCD

LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);
int i;    //and integer used to count

void setup()
{
   lcd.begin(20,4); 
   lcd.setBacklightPin(3,POSITIVE);
   lcd.setBacklight(HIGH);
   

  
   
    //Define the receiver pin and rate
    vw_set_rx_pin(12);       //Sets pin D12 as the RX Pin
    vw_setup(2000);       // Bits per sec
    vw_rx_start();           // Start the receiver PLL running
}

void loop()
{
   uint8_t buf[VW_MAX_MESSAGE_LEN];
   uint8_t buflen = VW_MAX_MESSAGE_LEN;
   
   if( vw_get_message(buf, &buflen) )
      {
        lcd.setCursor(0, 0);
        lcd.print("Depth is:");    
        lcd.setCursor(0,1);  
        
       for (i = 0; i < buflen; i++)
         { 
           lcd.write(buf); 
                    
         }
        
           lcd.print((char)223);
           lcd.print("Feet");
           
if (char < 17) 
{ digitalWrite(led,HIGH); 
      }
 else { 
digitalWrite(led,LOW); 
} 
}

Sorry didn't understand the code tags

Do we have to guess the error message?

You may wish to make the LED pin an output

I have it in my original post. The error is (char is not a template)

if (char < 17) That one?
char is a datatype, not a variable.

Next time, post the whole error message.

 'char' is not a template

 if (char < 17)

     ^~~~

Reciever_WORKING_ONE:49:5: error: expected primary-expression before 'char'

Reciever_WORKING_ONE:49:5: error: expected ')' before 'char'

Reciever_WORKING_ONE:55:1: error: expected '}' at end of input

 }

Okay thanks that is what I was thinking after doing some research. Do you have any suggestions on how to change it from a datatype to a variable?

Call it "whateverYouLike", but don't forget to define it .

E.g. "char whateverYouLike;"