Total Pageviews

Saturday, April 20, 2019

Delay off system using millis()

my original article

    In simple Arduino projects you can use delay command for have few seconds a led on and after that off, but in in this time program is halted. If you use millis() function, Arduino can execute other tests in program, not halt...
   In Arduino IDE program you cam find sketch named BlinkWithoutDelay
  In article Using millis() for timing you can find a good explanations
   I use this schematic for first test, using a push button and pull-up resistor on input
   If you upload delay_button.ino sketch, you will see next cases:
- standby state, led off:
- push buton, led off
- instantaneous, led on, time defined in sketch
- standby state, led off, again, waitting push button.
because I write the sketch using this chart
In Serial Monitor, you can see
   I change button with infrared module, schematic is
   For module sensor with normal state logic output (LOW in standby and HIGH when is triggered) sketch is delay_sensor.ino
and if you use other sensors with negative state logic output (HIGH in standby and LOW when is triggered) sketch is delay_sensor1.ino
    I made movie named delay off using millis()
    For this sketch(es), states are:
- stanfby, led off
- sensor is triggered, led is instant on
- led is on few seconds (selected in sketch), led is on
- after few seconds (selected in sketch), led is off
Also, in Serial Monitor, you can see the states:

2 comments:

  1. where is the code ???????? how we believe

    ReplyDelete
    Replies
    1. where is text:
      "If you upload sketch, you will see next cases:"
      go to https://github.com/tehniq3/delay/blob/master/delay_button.ino
      also you can find 2 other sketches with *.ino name :) but you neet to click on names

      Delete