In this demonstration, I’d like to show 3 different approaches towards mapping a predefined array of patterns or states of HIGH or LOW to an array of Yellow colored LEDs, with the selected pattern shown with Blue colored LEDs.
At the top of the code, by default, the AUTORUN is enabled to keep the patterns on auto cycling.
Please disable it as per the comments within the code to then be able and apply the desired function to run and select the patterns manually with buttons to demonstrate the same result using the 3 methods.
The methods demonstrated are:
1- Per individual index as one by one manual index mapping of patterns to both blue and yellow leds
2- For Loop increments index mapping of patterns to both blue and yellow leds
3- PORT level mapping using DDR and PORTx with binary codes mapping to PORTx
Board used is Arduino mega 2560.
Here is an animated preview.
Source code and pins connections diagram attached below.
patterns_mapping_pins_array.ino (21.2 KB)