<div dir="ltr">I don't often do other peoples "homework" as I personally learn more by doing it myself, but in this case I thought what the heck.  Hopefully you take a few minutes to see how I handled it.  I know others may have approached it differently.  Anyways, try the following code:<div><br></div><div><br></div><div><div>//constants</div><div>const int ledPin = 13;</div><div>const int sensorPin = 2;</div><div>const long stayOnPeriod = 2000;   // length of time to stay on (in milliseconds)</div><div><br></div><div>//variables</div><div>unsigned long turnOffTime = millis();  //Start with the led turned off</div><div><br></div><div>void setup() {</div><div>  pinMode(ledPin, OUTPUT);</div><div>  pinMode(sensorPin, INPUT);</div><div>}<br></div><div><br></div><div>void loop() {</div><div>  // check if the sensor is detecting then increase the time to stay on.</div><div>  if (digitalRead(sensorPin) == HIGH)</div><div>  {</div><div>    turnOffTime = millis() + stayOnPeriod;</div><div>  }</div><div>  </div><div>  if (turnOffTime > millis())</div><div>  {</div><div>    digitalWrite(ledPin, HIGH);</div><div>  }<br></div><div>  else</div><div>  {</div><div>    digitalWrite(ledPin, LOW);</div><div>  }</div><div>}</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 2, 2018 at 2:56 PM, Bruce Harding <span dir="ltr"><<a href="mailto:bsharding@rogers.com" target="_blank">bsharding@rogers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Dave,<br><br>I figure out why the delay wasn't working.  A stupid error.  I've looked at the millis thing and the blink without delay code, but I'm such a beginner I'm not sure how to take what I'm using and convert it to use millis.<br><br>====<br></div>bruce <br></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On 2 March 2018 at 14:28, Dave Hunt <span dir="ltr"><<a href="mailto:dave@huntgang.com" target="_blank">dave@huntgang.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think you need some non-blocking code in there.  The use of delay sits and waits and does not check the status of the motion detector while it is waiting.  So any time it is triggered, it should turn on the light and then "hang" before turning off the light and starting to check for motion again.<div><br></div><div>What I would do is use millis function.  Look at the blink without delay (non blocking code) for an example.  then anytime I saw montion I would change the counter to current millis + "on timer length"</div><div><br></div><div>Hope this helps.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 2, 2018 at 12:50 PM, Bruce Harding <span dir="ltr"><<a href="mailto:bsharding@rogers.com" target="_blank">bsharding@rogers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I'm trying to get the code for this project to work.  I want the LEDs to stay on<br>for 10 minute or continue on if more motion is detected. right now the LED strip<br clear="all"><div>turns off 2 seconds after no motion.<br><br>the code:<br><a href="https://gist.github.com/anonymous/8f0be0ffb6366ebe814c6d9b0ef7cd49" target="_blank">https://gist.github.com/anonym<wbr>ous/8f0be0ffb6366ebe814c6d9b0e<wbr>f7cd49</a><br><br>pics of the project: <br><a href="https://photos.app.goo.gl/QrgMDG1KMnpNUjdy2" target="_blank">https://photos.app.goo.gl/QrgM<wbr>DG1KMnpNUjdy2</a><br><br></div><div>I'm using the Grove Shield and Relay<br><a href="http://wiki.seeed.cc/Grove-Relay/" target="_blank">http://wiki.seeed.cc/Grove-Rel<wbr>ay/</a><br></div><div><br>PS. I've not coding experience<br><br><span>====</span><br><span></span><div class="m_2968523112927561351m_4293813679886981577m_-8707907899790980816gmail_signature"><div dir="ltr"><span>bruce<div><a href="http://faintfuzzies.ca" target="_blank">faintfuzzies.ca</a></div></span></div></div>
</div></div>
<br>______________________________<wbr>_________________<br>
Lab mailing list<br>
1. subscribe <a href="https://artengine.ca/mailman/listinfo/lab" rel="noreferrer" target="_blank">https://artengine.ca/mailman/l<wbr>istinfo/lab</a><br>
2. then email <a href="mailto:Lab@artengine.ca" target="_blank">Lab@artengine.ca</a> to send your message to the list<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><br></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_2968523112927561351gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span>====<br>bruce<div><a href="http://faintfuzzies.ca" target="_blank">faintfuzzies.ca</a></div></span></div></div>
</font></span></div>
</blockquote></div><br></div>