Total Pageviews

Showing posts with label millis(). Show all posts
Showing posts with label millis(). Show all posts

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:

Sunday, February 24, 2019

Measure times using millis()

   If you need to find the time what a button is pusshed or you want to use one button for made more function (short or long push / short, medium or long push) it can use millis() function with Arduino  language.
   Information for this thechnique (method) I found it on Doz's Blog.
   For test, I use a simple schematic (one button) and pushtime1button.ino program (sketch).
    For understand more ok the style of use, I tested also with 2 buttons, using pushtime2buttons.ino sketch.
     I made a short movie named measure times using millis() where is mase some tests: