LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to turn on and off leds

I have a Boolean Control Push Button, and 3 Boolean LED indicators.  The push button's mechanical action is "switch until released."  What I want to do is push the button and turn on LED 1.  When I push the button again, I want LED 1 to turn off, and LED 2 to turn on.  When I push the button a third time, I want LED 2 to turn off, and LED 3 to turn on.  When I push a button the 4th time I want LED 3 to turn off, and LED 1 to turn back on.  I don't know how to do this.  Any help would be greatly appreciated.  Thanks.
0 Kudos
Message 1 of 6
(3,775 Views)
There are many ways to do this. One possible solution is attached (LabVIEW 7.0).
 
(you don't say what should happen if you click a 5th time ;))
 
Also, can you explain why your button should be "switch until released"? This is not a very popular setting and rarely appropriate.
Message 2 of 6
(3,767 Views)
I do not have labview 7.0.....Can you tell me the most easy way to do this.....I would really appreciate it....Thanks
0 Kudos
Message 3 of 6
(3,763 Views)
Altenbach,

I downloaded the evaluation version of 8 to open up your .vi you made.  I then created that same code in 6.1 and it worked.  Thanks brother.  I appreciate your help.
0 Kudos
Message 4 of 6
(3,756 Views)

@leroy27336 wrote:
Altenbach,

I downloaded the evaluation version of 8 to open up your .vi you made.  I then created that same code in 6.1 and it worked.  Thanks brother.  I appreciate your help.
 


Is your problem solved men ??

if it is not I well tell you the solution.

First : I have defined yellow led as pin 6, green led as pin 5 , red led as pin 3, button as 4

I am working at arduino uno so let's begin

 

I will first define : int sensorvalue =digitalRead(4)

you should define a variable like saying : int variable = 0 for recording changes

then you should increase the amount of this variable every time the button is pressed like saying

if(sensor value == HIGH)

{ variable = variable + 1 // Increase the amount of the variable

Serial.println(variable);  // record the variable

delay(100);  

}

// Light the first Led (yellow led)

if(variable>=0 &&variable<=50)

{ analogWrite(yellow_led,255);

analogWrite(red_led,0);

analogWrite(green_led,0);

}

// Light the second led (green led)

if (variable>50 && variable<=100)

{

analogWrite(yellow_led,0);

analogWrite(red_led,0);

analogWrite(green_led,255);

}

// Light the third led (red led)

if (variable>100 && variable<150)

{

analogWrite(yellow_led,0);

analogWrite(red_led,255);

analogWrite(green_led,0);

}

// returning the variable to 0 

if(variable==150)

{variable=0;}

 

I will download the code and make sure you download the last version of  IDE 1.8.5

 I hope you understand.

and I hope this was helpful.

MOHAMAD

 

0 Kudos
Message 5 of 6
(3,025 Views)

Hi there ! Sorry they don't let me send you the code

0 Kudos
Message 6 of 6
(3,024 Views)