Chapter 4. Subtask 2: Randomly Light an LED

Subtask 2 will use the same circuit you assembled for Subtask 1; we will simply make a change to the programming that will light up the LED after a random number of seconds has elapsed. The parts required for Subtask 2 are identical to those listed in Chapter 3.

You can download the program for Subtask 2 online at http://examples.oreilly.com/0636920020882, or simply enter the code below into the Arduino IDE:

// MintDuino NoteBook 1 – Subtask 2 int ledPin = 7; // Digital Pin 7 for LED anode connection int ledWaitMin = 2000; // Set minimum wait time to 2000 milliseconds void setup() { // use noise on pin 1 to generate a random number randomSeed(analogRead(1)); pinMode(ledPin, OUTPUT); } void loop() { // ...

Get MintDuino now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.