Need help on battery monitor for rfid with LEDS

This is the code

// Pin for LEDs
#define LEDGREEN 10
#define LEDYELLOW 11
#define LEDRED 12
#define ANALOGBATTERY0

// variables
int analogValue = 0;
float voltage = 0;
int ledDelay = 800;

// threshhold
maximum float = 1.6;
medium float = 1.4;
minimum float = 0.3;

void setup () {
//We start the serial monitor
Serial.begin (9600);

// LED pins in output mode
pinMode (LEDGREEN, OUTPUT);
pinMode (YELLOW LED, OUTPUT);
pinMode (RED LED, OUTPUT);

}

void loop (){
// WE read the value of the analog input
analogValue =analogReald (ANALOGBATTERY);

//We get the voltage
voltage = 0.0048 * analogValue;
Serial.print ("Voltage:");
Serial.println (voltage);

// Depending on the voltage we show one LED or another
if (voltage> = maximum)
{
digitalWrite (LEDGREEN, HIGH);
delay (ledDelay);
digitalWrite (LEDGREEN, LOW);
}
els if (voltage <maximum && voltage> average)
{
digitalWrite (YELLOW LED, HIGH);
delay (led Delay);
digitalWrite (YELOW LED, LOW);
}
else if (voltage <medium && voltage> minimum)
}

// WE turn off all LEDs
digitalWrite (LEDVERDE, LOW);
digitalwrite (YELLOW LED, LOW);
digitalwrite (RED LED, LOW);

This is the error message we keep getting

Arduino: 1.8.12 (Windows 10), Board: "Arduino Uno"

SiennaRbattres:16:1: error: 'maximum' does not name a type

maximum float = 1.6;

^~~~~~~

SiennaRbattres:17:1: error: 'medium' does not name a type; did you mean 'memmem'?

medium float = 1.4;

^~~~~~

memmem

SiennaRbattres:18:1: error: 'minimum' does not name a type

minimum float = 0.3;

^~~~~~~

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino: In function 'void setup()':

SiennaRbattres:26:10: error: 'YELLOW' was not declared in this scope

pinMode (YELLOW LED, OUTPUT);

      ^~~~~~

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino:26:10: note: suggested alternative: 'LEDYELLOW'

pinMode (YELLOW LED, OUTPUT);

      ^~~~~~

      LEDYELLOW

SiennaRbattres:27:10: error: 'RED' was not declared in this scope

pinMode (RED LED, OUTPUT);

      ^~~

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino: In function 'void loop()':

SiennaRbattres:33:29: error: 'ANALOGBATTERY' was not declared in this scope

analogValue =analogReald (ANALOGBATTERY);

                         ^~~~~~~~~~~~~

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino:33:29: note: suggested alternative: 'ANALOGBATTERY0'

analogValue =analogReald (ANALOGBATTERY);

                         ^~~~~~~~~~~~~

                         ANALOGBATTERY0

SiennaRbattres:33:16: error: 'analogReald' was not declared in this scope

analogValue =analogReald (ANALOGBATTERY);

            ^~~~~~~~~~~

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino:33:16: note: suggested alternative: 'analogRead'

analogValue =analogReald (ANALOGBATTERY);

            ^~~~~~~~~~~

            analogRead

SiennaRbattres:41:16: error: expected primary-expression before '=' token

if (voltage> = maximum)

            ^

SiennaRbattres:41:18: error: 'maximum' was not declared in this scope

if (voltage> = maximum)

              ^~~~~~~

SiennaRbattres:47:1: error: 'els' was not declared in this scope

els if (voltage <maximum && voltage> average)

^~~

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino:47:1: note: suggested alternative: 'gets'

els if (voltage <maximum && voltage> average)

^~~

gets

SiennaRbattres:53:1: error: 'else' without a previous 'if'

else if (voltage <medium && voltage> minimum)

^~~~

SiennaRbattres:53:20: error: 'medium' was not declared in this scope

else if (voltage <medium && voltage> minimum)

                ^~~~~~

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino:53:20: note: suggested alternative: 'memmem'

else if (voltage <medium && voltage> minimum)

                ^~~~~~

                memmem

SiennaRbattres:53:39: error: 'minimum' was not declared in this scope

else if (voltage <medium && voltage> minimum)

                                   ^~~~~~~

SiennaRbattres:54:1: error: expected primary-expression before '}' token

}

^

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino: At global scope:

SiennaRbattres:57:14: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite (LEDVERDE, LOW);

          ^

SiennaRbattres:58:14: error: expected constructor, destructor, or type conversion before '(' token

digitalwrite (YELLOW LED, LOW);

          ^

SiennaRbattres:59:14: error: expected constructor, destructor, or type conversion before '(' token

digitalwrite (RED LED, LOW);

          ^

SiennaRbattres:60:1: error: expected declaration before '}' token

}

^

exit status 1
'maximum' does not name a type

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Should be
Float maximum = 1.6;

You have your other errors in the same vane .

Post in the wrong place so I moved it here.

Thanks that worked but now i have a different problem

Arduino: 1.8.12 (Windows 10), Board: "Arduino Uno"

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino: In function 'void setup()':

SiennaRbattres:26:10: error: 'YELLOW' was not declared in this scope

pinMode (YELLOW LED, OUTPUT);

      ^~~~~~

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino:26:10: note: suggested alternative: 'LEDYELLOW'

pinMode (YELLOW LED, OUTPUT);

      ^~~~~~

      LEDYELLOW

SiennaRbattres:27:10: error: 'RED' was not declared in this scope

pinMode (RED LED, OUTPUT);

      ^~~

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino: In function 'void loop()':

SiennaRbattres:33:29: error: 'ANALOGBATTERY' was not declared in this scope

analogValue =analogReald (ANALOGBATTERY);

                         ^~~~~~~~~~~~~

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino:33:29: note: suggested alternative: 'ANALOGBATTERY0'

analogValue =analogReald (ANALOGBATTERY);

                         ^~~~~~~~~~~~~

                         ANALOGBATTERY0

SiennaRbattres:33:16: error: 'analogReald' was not declared in this scope

analogValue =analogReald (ANALOGBATTERY);

            ^~~~~~~~~~~

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino:33:16: note: suggested alternative: 'analogRead'

analogValue =analogReald (ANALOGBATTERY);

            ^~~~~~~~~~~

            analogRead

SiennaRbattres:41:16: error: expected primary-expression before '=' token

if (voltage> = maximum)

            ^

SiennaRbattres:47:1: error: 'els' was not declared in this scope

els if (voltage <maximum && voltage> average)

^~~

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino:47:1: note: suggested alternative: 'gets'

els if (voltage <maximum && voltage> average)

^~~

gets

SiennaRbattres:53:1: error: 'else' without a previous 'if'

else if (voltage <medium && voltage> minimum)

^~~~

SiennaRbattres:54:1: error: expected primary-expression before '}' token

}

^

C:\Users\nxtechuser\Documents\Arduino\SiennaRbattres\SiennaRbattres.ino: At global scope:

SiennaRbattres:57:14: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite (LEDVERDE, LOW);

          ^

SiennaRbattres:58:14: error: expected constructor, destructor, or type conversion before '(' token

digitalwrite (YELLOW LED, LOW);

          ^

SiennaRbattres:59:14: error: expected constructor, destructor, or type conversion before '(' token

digitalwrite (RED LED, LOW);

          ^

SiennaRbattres:60:1: error: expected declaration before '}' token

}

^

exit status 1
'YELLOW' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Typos everywhere.
Check every word in your code.
Upper/lower case also matters.

You define the yellow LED as LEDYELLOW.
Then you use YELLOW LED and YELOW LED in the code.
Similar typos for the other LEDs.
analogReald should be analogRead, etc...
Leo..

Repost your code using code tags as outlined in the forum guidelines. Also post an annotated schematic showing how this is connected, frizzies do not work for me or many others. We need both as they interact with each other and your messed up labels totally confuse the problem. By chance is this the output of one of the AI systems?

No you have exactly the same problem, which is that you do not know the basics about how C programing works. Variables have names and the name must:-

  1. not contain any spaces
  2. case matters so 'yellow' is treated as a different variable from 'Yellow'
  3. all instances of the same variable must be spelt the same, with the same case, otherwise the computer will think it is a different variable and will find that it hasn't been declared.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.