Digital I/O

Part 1:

“Solder a circuits from Monday to a prototyping board (2 leds in series or parallel).”

For part one, I remade my in series circuit by soldering all the components to a small perf board.  The result was a cute little breakout board with three tiny green LEDs, one 100 Ω resistor and a tiny button.  Simple but useful

This slideshow requires JavaScript.

Part 2:

“Build a circuit with 2 or more digital inputs. Use LEDs (regular or RGB) or neopixels as outputs. Program your microcontroller so that each input has a unique output.”

Parts: micro-controller, breadboard, neopixel strip, button, switch, LED, resistors.  

My idea was to have a circuit that has an “on/off” toggle switch and a button that, when pressed, lights up a green LED and changes the light animation from  slow blinking blues and purples (Chill mode) to brighter flashing reds and yellows (Burn mode) on a neopixel strip.

schematic showing hook up of micro-controller, two switches, one LED, and a short RGB LED neopixel strip.

I had a bit of trouble getting the buttons to work at first, but then our instructor pointed out I was missing part of the code.  After working out that hang up, I was able to get my light components up and running.  I like working with the ALA (Arduino Light Animation) Library.  This library has some nice “twinkly” options that I’ve really enjoyed using in other projects, and it is easy to add to the Arduino IDE.

Test of the button and toggle with green LED


Here is the code:

#include <AlaLedRgb.h>
AlaLedRgb rgbStripChill;
AlaLedRgb rgbStripBurn;
AlaLedRgb rgbStripoff;
AlaSeq Burn[] =
{ ALA_OFF, 100, 100, alaPalNull },
{ ALA_FIRE, 1000, 6000, alaPalFire },
{ ALA_OFF, 100, 100, alaPalNull },
AlaSeq Chill[] =
{ ALA_OFF, 100, 100, alaPalNull },
{ ALA_SPARKLE2, 1000, 6000, alaPalCool },
{ ALA_OFF, 100, 100, alaPalNull },
AlaSeq off[] =
{ ALA_OFF, 100, 100, alaPalNull },
int buttonState;
int toggleState;
void setup()
pinMode(3, INPUT);
pinMode(6, OUTPUT);
rgbStripBurn.initWS2812(5, 12);
rgbStripChill.initWS2812(5, 12);
rgbStripoff.initWS2812(5, 12);
void loop()
buttonState = digitalRead(3);
toggleState = digitalRead(2);
Serial.print("button ");
Serial.print("toggle ");
if (toggleState == HIGH && buttonState == HIGH)
{digitalWrite(6, HIGH);
else if (toggleState == HIGH && buttonState == LOW)
{digitalWrite(6, LOW);
{ Serial.print("off");

view raw

Object: LAB 2

hosted with ❤ by GitHub

Final video

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s