Art of a button - Advanced AVR 3.0 Core - Sleep, watchdog, interrupt

Channel:
Subscribers:
580
Published on ● Video Link: https://www.youtube.com/watch?v=g5URdx3cPq4



Duration: 2:20
0 views
0


Instead of keeping time using a software counter, the long delay time is configured directly using the watchdog timer, since it has a range from 16ms to 2 seconds. The advantage is simpler code and thus more robust result. With this driver, the amount of clicks is limitless as long as the previous button and the current button presses occur within 500ms. The button denounced time is at a fixed 16ms interval. For powering up the MCU, a longer button denounce time can be used, but since double click here is very robust and efficient, double click can be used as the power ON trigger.

Hold to turn on/off is different from press and release and wait for 500ms. Hold trigger doesn't need the button to be released, but a long 500ms holding time is required for it to register, so here the active LOW reading is more important. This is easily implemented with the normal watchdog button denounce timer set to a longer delay period, so normal button denounce is 16ms, power On/Off denounced is 500ms. Switching between these two is controlled by a Boolean power.up. If power.up is 0, then button denounce delay is 500ms, else 16ms.

Power up and power down may seem a simple concept, but it's not as it seems. Here power down boolean is used as a simple way to turn off the MCU in the main loop. Different sleep mode can be picked before setting this switch. Power up is also has nothing to do with the status of which sleep mode the MCU is currently in. It's only used to switch between 16ms and 500ms button debounce delay, so before it's defined as power up, the button is required to be pressed longer than 500ms for the switch to work, a way to avoid accidentally pressing a button. Implementing a hold-500ms to turn ON the MCU works very well like this, but the hold-500ms to turn OFF the MCU is not possible with this cheat, since if the 500ms long button debounce delay is picked, then other double-clicks will not work.

To sum up: 1, single-click the button to turn ON and OFF a LED; 2, double-click the button to change toggle between 2 brightness levels; 3, triple-click to lock the button to 500ms debounce timer, and turning off the MCU and LED; Once locked, the button needs to be hold down for 500ms to switch it back ON.




Other Videos By Flyandance


2023-02-17Script cowboy - the power of one line of code
2023-02-15Bootloader Pro - Advanced AVR 3.0 Core - AVR-C 2.0 sucks BBC
2023-02-11Juno ABC - Advanced Button Core 4.0 - Sleep mode ultra low power
2023-02-07My Coffee ritual 2.0 - Simple Minimalistic - Dry milk + sugar
2023-02-03Sleep mode - Advanced AVR 3.0 - Atiny13 watchdog less than 100nA - Peripheral leakage current Button
2023-02-02Definition of good soup - Chicken Turmeric
2023-02-01Sleep mode - Advanced AVR 3.0 - 32kHz Timer2 Asynchronous mode - Atmega8 low power 8-12uA
2023-01-31Sleep mode - Advanced AVR 3.0 - 1 second timer - Atmega8 low power down + watchdog + eeprom MCU
2023-01-30Watchdog - Advanced AVR 3.1 Core - Atmega8 + EEPROM + External RC + Low power timer + MCU underclock
2023-01-26Juno ABC - Advanced Button Core - TTP223 Attiny10 AVR - LED watchdog Sleep PWM Timer
2023-01-23Art of a button - Advanced AVR 3.0 Core - Sleep, watchdog, interrupt
2023-01-08Juno Binary Retro 2.0 Color - Neon Lamp Clock - Nixie tube alternative RTC MCU AVR
2023-01-03Light Guard 1.0 - Final product - 3D Printed Casing PIR MCU LED Sleep Low power AVR Dimmer PWM
2023-01-01Advanced AVR 3.0 Core - Light Guard 1.0 - 3D-printed PIR LED light with built-in Charger - Sleep
2022-12-31Advanced AVR 3.0 Core - Sleep, software and hardware-based power button Double click
2022-12-28Advanced AVR 3.0 Core - Watchdog - Timer Sleep button Power Switch
2022-12-14Fixing a Power supply On a Bionaire BCH9214RE Heater
2022-11-30Juno BCR 2.0 - Part 3 (Final Product) Neon Lamp Clock - Nixie tube alternative RTC MCU AVR DC-DC Kit
2022-11-26Juno BCR 2.0 - Part 3a - Draft 1: 24 Neon Lamp clock - Nixie Tube alternative
2022-11-25Juno BCR 2.0 - Part 2b - Final Library Test - Juno Button Advanced Core 3.0 Interrupt-based
2022-11-22Juno BCR 2.0 - Part 2 - Lib Test - 5 Neon Lamp Brightness level