This guide will help you understand how to program the LEDs available on the Engduino, using the Touch Develop Engduino Library.

First of all, in order to program the Engduino, you need to initialise the library. Do that by writing the command Engduino -> init in the beginning of the code.


8.a. Program all of the LEDs

8.b. Program specific LEDs



Standard commands

  1. Using pre-set colours:

    Engduino -> set all LEDs(colors ->colour)

    • colors ->colour - Refers to any colour of choice from “colors”, for example red, green, yellow etc.

  2. Turning off LEDs:

    Engduino -> set all LEDs(colors ->black)

  3. In order to turn the LEDs off, all we need to do is set them to black.
  4. Custom colours:

    Engduino -> set all LEDs(colors -> from argb(A,R,G,B)

    • A - The alpha. This changes the transparency of the new colour. Choose a number from 0 to 255. Keep it at 255 to make an intense colour.
    • R, G, B - These letters must each be replaced with a value from 0 to 255. The higher the number, the greater the intensity of the given colour.

      o Careful: If you choose to post a mathematical function to the wall, the only thing that will be displayed is the result;


Advanced settings - delay

Engduino -> delay (milliseconds)

  • This programs the script to wait a given number of milliseconds before moving on to the next instruction. This command can have some great uses and allows for things like creating flashing lights.

    Tutorial

    To further understand how LEDs work, try running the following tutorial:

  • "Flashing Lights"


    Exercises

    Now use the things you have learned in order to solve more difficult exercises.

    1. Create a script that uses variables to allow the user to define their own colour, then have the lights display that colour.
    2. Using a variable that cycles around the values 1-16, set a single LED to the colour of your choice, having it slowly moving around the Engduino.

      Tips: For this problem, you might need to use the mod function math -> mod(a,b) which returns the remainder of a's division by b.

      • Extend this by removing any trail the light may leave behind it.


    Remember there is always more you can do! Try out what you have learnt and set your own challenges.



    PREVIOUS LESSON

    NEXT LESSON

    BACK TO INDEX