Go Down

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


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.


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


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.
The art of getting good answers lies in asking good questions.


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


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