The circuit theory diagram shown in Figure 4-3 can easily be converted into a cool electronic gadget. You can build a Twin LED Flasher using an Arduino, two 330 ohm resistors, and LEDs, as shown in Figure 4-4. The Twin LED Flasher circuit schematic diagram is shown in Figure 4-5. To make the flasher device compact, you can build it on the MakerShield, as shown in Figure 4-6. Uploading the Blink sketch to the Arduino allows you to test the MakerShield and the Twin LED Flasher. The Blink sketch for the electronic flasher is shown in Example 4-1.
Figure 4-4. Twin LED Flasher Fritzing diagram
TECH NOTE
The omega symbol (Ω) and the word ohm are used interchangeably. For example, 10KΩ, 10K, and 10K ohm indicate the same value.
Figure 4-5. Twin LED Flasher: LED1 and LED2 with 330 ohm resistors are wired in parallel to the Arduino D13 pin
TECH NOTE
The Build a MakerShield guide, part of Make: Projects, includes step-by-step directions for building your own prototyping shield.
Figure 4-6. MakerShield Twin LED Flasher
Example 4-1. Blink sketch
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output:
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Leave a Reply