Counting from 1 to 9 with LEDs, Python code and the mraa library
Once we finish the wirings and we make sure that all the components and the wires are in the right place, we can write our first version of the Python code to count from 1 to 9 with the LEDs, transfer it to the board via SFTP and execute it.
We will write a few lines of Python code that will use the mraa
library to run the following steps to count from 1 to 9, with a 3 seconds pause between each step:
- Turn on LED1
- Turn on LED1 and LED2
- Turn on LED1, LED2 and LED3
- Turn on LED1, LED2, LED3 and LED4
- Turn on LED1, LED2, LED3, LED4 and LED5
- Turn on LED1, LED2, LED3, LED4, LED5 and LED6
- Turn on LED1, LED2, LED3, LED4, LED5, LED6 and LED7
- Turn on LED1, LED2, LED3, LED4, LED5, LED6, LED7 and LED8 ...
Get Internet of Things with Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.