Example 1: Blinking LEDS

Code


/*In this simulation we can control the blinking of the three LEDs (yellow, green and red) that are incorporated in the robot's motherboard*/

/*In my case, I have configured the code in such a way that the LEDs light up synchronously, from left to right*/

/*We include the appropriate libraries to be able to activate certain commands and instructions*/

#include <Wire.h>
#include <Zumo32U4.h>

/*In the void setup section it is not necessary to add anything since in the circuit we do not have to assign pins, outputs, inputs, etc*/

void setup()
{

}

/*In void loop is where the blink instructions will be given, repeating them in a loop, as the name indicates*/

void loop()
{

/*Here we turn on only the first LED, indicating it and assigning it a 1 in parentheses, which as a general rule is usually attributed to the ignition order*/

  ledRed(1);
  ledYellow(0);
  ledGreen(0);

/*We also indicate the time that the LED will be on, in this case with a delay of 0.2 seconds*/
  
  delay(200);

/*Later we command the red LED to turn off (this time numbered 0) and the yellow LED to turn on (also numbered 1), still keeping the green LED off*/
  
  ledRed(0);
  ledYellow(1);
  ledGreen(0);

/*We apply the same delay as before*/
  
  delay(200);

/*And finally we turn off the second LED with 0 and turn on the green LED with 1, which will turn off again when the loop starts again*/
  
  ledRed(0);
  ledYellow(0);
  ledGreen(1);

/*We assign for the third time the same delay as always*/
  
  delay(200);
}


Video of the Circuit