Go Down

Topic: LED glowing time calculation (Read 471 times) previous topic - next topic

vennishmuthu

Hai All,
     By using arduino uno I want to display the LED glowing time in serial window say example if I connected one LED in 2 pin and I glow it for 30 seconds means in the serial window I want to show 30 sec like that. Please  guide me.

johnwasser

What do you mean by "I glow it for 30 seconds"?  How is the LED turned on and off?
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

PaulS

Quote
How is the LED turned on and off?

Equally, why can't you record when that happens, using millis()?

Every time the LED turns off, subtract the on time from the off time, to get the duration, and increment the total duration by that amount.

terryking228

vennishmuthu, maybe start with one of the example software sketches that comes with every Arduino installation: Use the menus to find:

File>Examples>Digital>BlinkWithoutDelay

Use that to understand about the millis() variable. 

Add a variable to save the time the LED will be on.  Send that data also to the serial monitor. 

Start experimenting and learning...

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Go Up