KontrolIR V1.00.ino: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 7: | Line 7: | ||
* Then we initialise all non-keypad related pins - for the optional IR receivers and I2C EEPROM snd their related power supply via GPIO. The default state for these devices is powered dowm. | * Then we initialise all non-keypad related pins - for the optional IR receivers and I2C EEPROM snd their related power supply via GPIO. The default state for these devices is powered dowm. | ||
* Next we init the keypad buttons. Each button is mapped to a particular Row/Col combination.''(see section on pin outs)'' The 7 Cols are defaulted to INPUT_PULLUP and the 7 Rows are defaulted to OUTPUT LOW. This allows us to make use of PCINT interrupts on the COL pins to detect when a button is pressed during PWR_DOWN mode. Once the MCU wakes up ''(Triggered by the PCINT)'', we cimmediately check to see which COL was pulled LOW and search each ROW to find the actual button that was pressed. If more than one button was pressed we assume the first one found is the one that was pressed. | * Next we init the keypad buttons. Each button is mapped to a particular Row/Col combination.''(see section on pin outs)'' The 7 Cols are defaulted to INPUT_PULLUP and the 7 Rows are defaulted to OUTPUT LOW. This allows us to make use of PCINT interrupts on the COL pins to detect when a button is pressed during PWR_DOWN mode. Once the MCU wakes up ''(Triggered by the PCINT)'', we cimmediately check to see which COL was pulled LOW and search each ROW to find the actual button that was pressed. If more than one button was pressed we assume the first one found is the one that was pressed. | ||
* Next we init the LED pin as output and set it LOW. This is oneof a set of LED macros defined in the header file. | |||
'''Loop''' | '''Loop''' |
Revision as of 03:57, 8 October 2019
> KontroLIR Home > back
This is the min Arduino sketch file, containing both the setup and loop functions.
Setup
- First we init the MCU frequncy divider to match the setting selected in the Arduino IDE. The crystal used is 16MHz, so for 8MHz operation the clock needs to be divided by a factor of 2. We suggest using 8Mhz with this firmware for the best balance between battery and IR performance. With other firmware loaded (e.g. IRremote), by all means use 16MHz etc.
- Then we initialise all non-keypad related pins - for the optional IR receivers and I2C EEPROM snd their related power supply via GPIO. The default state for these devices is powered dowm.
- Next we init the keypad buttons. Each button is mapped to a particular Row/Col combination.(see section on pin outs) The 7 Cols are defaulted to INPUT_PULLUP and the 7 Rows are defaulted to OUTPUT LOW. This allows us to make use of PCINT interrupts on the COL pins to detect when a button is pressed during PWR_DOWN mode. Once the MCU wakes up (Triggered by the PCINT), we cimmediately check to see which COL was pulled LOW and search each ROW to find the actual button that was pressed. If more than one button was pressed we assume the first one found is the one that was pressed.
- Next we init the LED pin as output and set it LOW. This is oneof a set of LED macros defined in the header file.
Loop
> KontroLIR Home > back