O'Reilly logo

Internet of Things with Python by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required