I am trying led counter based on radar sensor

can you check below cide is correct , my intention is whenver radar sensor output is high first LED will be switched ON , then second time if radar goes high again then second LEd swicthes on , third time when rardar switches to high then 3rd LED switches on and so onn till 4 LEds applied delay for stability , at the same time led1 , 2 & 3 are on one by one till they switch off push switch

full Sketch : compiling & uploading without error but execution not functioninig
int Sensor = 2; // RCWL-0516 Input Pin
int Pbut = 3; // Push button Input Pin
int LED = 13; // LED Output Pin
int LED2 = 4; // LED Output Pin
int LED3 = 5; // LED Output Pin
int LED4 = 12; // LED Output Pin

int sensorval = 0; // RCWL-0516 Sensor Value
int pbval = 0; // Push button value

void setup() {
Serial.begin(9600);
pinMode (Sensor, INPUT); // RCWL-0516 as input
pinMode (Pbut, INPUT); // Push button as input
pinMode (LED, OUTPUT); // LED as OUTPUT
digitalWrite(LED, LOW); // Turn LED Off
}

void loop1(void){
delay(2000); // waits for a second
pbval = digitalRead(Pbut); // Read Push button value

if (pbval == HIGH) {
digitalWrite(LED, HIGH); // Turn LED ON
Serial.print(LED);
delay(5000); // waits 5 second
sensorval = digitalRead(Sensor); // Read Sensor value
}}

void loop2(void){
if (sensorval == HIGH && LED == HIGH)
{
digitalWrite(LED2, HIGH); // Turn LED2 On
Serial.print(LED2);
delay(60000); // waits for 60 second
}}
void loop3(void){
if (sensorval == HIGH && LED == HIGH,LED2==HIGH)
{
digitalWrite(LED3, HIGH); // Turn LED3 On
delay(60000); // waits for 60 second
}}
void loop4(void){
if (sensorval == HIGH && LED == HIGH,LED2==HIGH,LED3==HIGH )
{
digitalWrite(LED4, HIGH); // Turn LED4 On
delay(60000); // waits for 60 second
}}

void loop(void) {
pbval = digitalRead(Pbut); // Read Push button value
loop1();
loop2();
loop3();
loop4();
if (pbval == LOW) {
digitalWrite(LED, LOW); // Turn LED Off
digitalWrite(LED2, LOW); // Turn LED Off
digitalWrite(LED3, LOW); // Turn LED Off
digitalWrite(LED4, LOW); // Turn LED Off
Serial.print(LED);
}}

You gave LED the value 13.
HIGH has the value 1.
They are never, ever going to be equal.

I'm not sure you want a comma operator there, but see also my last comment

Please remember to use code tags when posting code

LED outpin13 not value

Both the compiler and I disagree.

can you give me correct code for it

Turning on or off an input pin's built-in pullup resistor isn't going to do much to whatever is connected to the pin.
Did you forget a pinMode?

No - I don't have your hardware, so I could never test adequately.

This must have given you a clue that what was happening wasn't what you expected?

yes dear , i was trying to see output changes in serial monitor , i am using Wemos mini d1 hardware & RCWL-0516 radar sensor

i have updated the PInmode for all variables , forget to setup this

So, what does the code look like now, with all those corrections?
And how does it behave?

as you indicated the If statement looks incorrect , I may have to assign the Out put as integer to another variable and assign here am i right

f (sensorval == HIGH && LED == HIGH,LED2==HIGH)

to show led output as 1 ( high) in if statement

My usual answer is the value on the LED output pin is the last value that you wrote to it.
Or you could read it.

what is the read command for ou put status

now it started reading all the loop & updating in serial print but i need the logic of led2 on only i f the Led1 is active & sensor value is High and so on for led3 & led4

I'm sorry, I can't help with code I can't see.

Thanks dear , I am trying different approach now, hope that will work,
your hint & support was very helpful

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