PROJECT: Countdown LED & Speaker Alarm
Step 1 - Build the Project

Countdown LED & Speaker Alarm Hookup: 1 speaker in pin A5 and 1 LED in pin 13. Remember the shorter leg of the LED is ground.

Topics Covered:


This code uses the delay - your countdown timer - to delay the beginning of the loop, which holds the synchronized LED and speaker alarm.

Step 2 - Upload the Code

/* * Create a countdown timer in the setup, then run an alarm with lights * and sound when the time is up */ void setup() { pinMode(A5,OUTPUT); //speaker pinMode(13,OUTPUT); //LED delay(6000); //The delay is the timer's countdown } void loop(){ digitalWrite(13,HIGH); tone(A5,450); delay(500); tone(A5,750); delay(500); noTone(A5); delay(500); } // Insert digitalWrite() commands so that the LED flashes with each tone // (c) 2017 Let's Start Coding. License:

Step 3 - Read the Walkthrough

After setting up both the speaker and the light as outputs, you can use the delay command to put the code on hold. The number of milliseconds within delay can range up to about 4.29 million, so your countdown can last over an hour if you want!

After the delay period has run out, the code drops into the loop, where it will run forever until the power to the Maker Board is turned off or the board is reset.