G+_Daniel Shyne Posted April 30, 2018 Share Posted April 30, 2018 Way back on episode 178, Father Robert used the arduino and ultrasonic sensor to make a parking sensor for your parents. I've kept that episode in the back of my mind and I'm now working on that for my wife. At the end of the project Brian asked if the LED's would stay on. Father Robert said the WS2182 LED's would stay on and he'd have to look at using an RTC to be able to turn the LED's off. I was wondering if there was a way to turn the LED's off after a certain amount of seconds or after a delay without using an RTC. I also would like the entire WS2182 ring I'm using to flash red when it's time to stop. Is there anyone out there smarted than me about arduino coding? The code I'm using is in the show notes at:https://twit.tv/shows/know-how/episodes/178?autostart=false Thanks in advance, Dan Shyne Link to comment Share on other sites More sharing options...
G+_Travis Hershberger Posted April 30, 2018 Share Posted April 30, 2018 You can use the built in timer for things like that, where the exact timing isn't critical. An RTC is important for keeping accurate time and keeping it set through power loss. I'm your case, I'd think you would be just fine without one. I just don't have the programming reference in front of me to give you some sample code. Link to comment Share on other sites More sharing options...
G+_Paul Hutchinson Posted April 30, 2018 Share Posted April 30, 2018 Just skim watched the episode to see what timing they were talking about and it's clear an RTC is way overkill for that application. As Travis Hershberger says the internal timers will be more than adequate. Worst case errors with the built in timers is +/- 0.02% or better which is no good for long time keeping (~= +/- 100 minutes per year) but no problem for short term timing. Link to comment Share on other sites More sharing options...
G+_Ben Reese Posted April 30, 2018 Share Posted April 30, 2018 arduino.cc - Arduino Reference I'd use (and have in the past) the millis() function to update a variable (stoppedTime) when it detects a change in distance. Then watch that variable to see if (millis() - stoppedTime) > 45000. If so, turn off the LEDs. millis() returns an unsigned long, so "stoppedTime" - or whatever you name your variable - should unsigned long also. Link to comment Share on other sites More sharing options...
G+_Daniel Shyne Posted April 30, 2018 Author Share Posted April 30, 2018 Thank you all for your help. I'll look into using the millis(). Link to comment Share on other sites More sharing options...
Recommended Posts