Simple timer

We'll start with something simple. 

We'll use all of the LEDs on Spencer and make them light up, and turn off in a loop every second. 

To begin, drag the "loop forever" block from the "Loops" block section onto the drawing area. 



This block will ensure that the code inside it is executed all the time in loops. 

Firstly, we want all of the LEDs to turn off, and for that we'll need the "fill frame with 0" block from the "Matrix" block section. 

Don't change the 0 for now. 



To run the code on the matrix, you must always include the "push frame to matrix" section; otherwise, the code will fail.



Because the following step will be to turn on the LEDs, we must include a one-second delay between these two activities. 

Go to the "Time" block section, and you'll find this block: 



It's time to turn on the matrix. 

To do that, duplicate the "fill frame with 0" block. 

This time, we'll change the 0 to 255



To ensure that the code runs properly, add another "push frame to matrix" block. 



Finally, add the "sleep 1 second" block at the end because that is the amount of time we want to pass before the code runs in loops over and again. 



Click on the Run button, and check the code!

Plans and prices

Subscribe and get a new STEM Box project delivered to your doorstep every 3 months. Select your billing model:

3 months

$99/Box

2 years

$79/Box

Save $160 + Free Tools pack
Boxes ship every month
Free worldwide shipping
Shipped from US, Canada, UK, Australia or EU
Subscription renews automatically
Cancel anytime

Plans and prices

Subscribe and get a new Wacky Robots project delivered to your doorstep every month. Select your billing model:

1 month

$38/Box

6 months

$33/Box

Save $30 + Free Tools pack

1 year

$30/Box

Save $96 + Free Tools pack
Boxes ship every month
Free worldwide shipping
Shipped from US, Canada, UK, Australia or EU
Subscription renews automatically
Cancel anytime