Project tutorial
Interactive LED Name

Interactive LED Name © GPL3+

Name on a box that lights up and has three different patterns that provide a cool light show.

  • 2,667 views
  • 2 comments
  • 7 respects

Components and supplies

Necessary tools and machines

Lasercutter
Laser cutter (generic)
09507 01
Soldering iron (generic)

Apps and online services

About this project

Our project is meant to be an interactive toy for children that can be customized to put any child's name on it. The name can blink, light up like a color wave, and loop through each letter individually at a certain pace. We decided to make this project because we thought that children would enjoy colorful lights that spell out their name and light up in a few different patterns to avoid getting bored of it too quickly. This project was also a challenge on the physical building and programming side which made it that much more interesting!

Tutorial

  • Set up the shift registers on a breadboard with 1-2 spaces between each, and follow this fritzing diagram to properly daisy chain and connect them to the arduino.

  • Add the accelerometer to the end of the breadboard where there is space and follow this hookup guide to wire it up, only wire the four left wires in the diagram because that is all that's needed (Don't forget that this accelerometer can only take 3.3V otherwise it can be damaged):
  • Connect the piezo alarm's small lead to a potentiometer that will control the volume and connect the longer lead to digital pin 9 on the arduino.
  • Get the second breadboard and use resistors to link each shift register pin for each LED. I recommend taping the breadboards to the bottom side of the enclosure to prevent movement of the resistors.
  • When you get your cutout for your enclosure, place the LED diodes through the holes with the short lead facing either right or left, but make sure that all the LEDs are put in the same way. Then, bend them about 45 degrees to make soldering easier. Solder the negative lead (short one) to the next closest negative lead and do this for all LEDs, so that they are all connected. Then solder a piece of wire (preferably black) that can reach the arduino's ground pin when inside the finished product.
  • Cut wire that is long enough that can reach the breadboard from the LEDs depending on how tall your enclosure is and solder the wire to the longer lead of each LED and repeat until all LEDs have a wire attached. Test by connecting the LEDs to their appropriate pin on the breadboard and connecting the grounding wire to see if they all turn on, if any of them don't turn on then fix the connections that you previously soldered.
  • Place the buttons/switches into their appropriate sockets/holes and solder wire to them that is long enough to reach the Arduino.
  • When you are ready to attach the wires from the LED to the breadboard follow this diagram that shows where each wire should go.
  • When complete squish all the components together and use wood glue to close the box and connect a 9V battery to the Arduino as a power supply.

Code

Interactive LED NameArduino
This code runs certain light patterns depending on which button/switch is clicked/flipped.
#include <SoftReset.h>

#include <SparkFunLIS3DH.h>


#include <Wire.h>
#include <SPI.h>

//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;

int j = 0;
int mode = 0;
int blinkBtn = 4;
int waveBtn = 2;
int loopBtn = 3;
int masterSwitch = 5;
int blinkBtnState, waveBtnState, loopBtnState, masterState;
int speedPot = A0;
int speedValue = 0;
int master = 0;
int buzzer = 9;
LIS3DH myIMU;
int reset = 6;
//holders for infromation you're going to pass to shifting function
byte waveOne, waveTwo, waveThree, waveFour, waveFive, loopOne, loopTwo, loopThree, loopFour, loopFive;
byte waveDataOne[16], waveDataTwo[16], waveDataThree[16], waveDataFour[16], waveDataFive[16];
byte loopDataOne[10], loopDataTwo[10], loopDataThree[10], loopDataFour[10], loopDataFive[10];


void setup() {
  digitalWrite(reset, HIGH);
  delay(200);
  pinMode(reset, OUTPUT);

  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(blinkBtn, INPUT_PULLUP);
  pinMode(waveBtn, INPUT_PULLUP);
  pinMode(loopBtn, INPUT_PULLUP);
  pinMode(buzzer, OUTPUT);
  pinMode(masterSwitch, INPUT_PULLUP);
  myIMU.begin();
  Serial.begin(9600);
  MCUSR = 0;
  loopDataOne[0] = 1;
  loopDataOne[1] = 3;
  loopDataOne[2] = 6;
  loopDataOne[3] = 12;
  loopDataOne[4] = 24;
  loopDataOne[5] = 48;
  loopDataOne[6] = 96;
  loopDataOne[7] = 192;
  loopDataOne[8] = 128;
  loopDataOne[9] = 0;

  loopDataTwo[0] = 2;
  loopDataTwo[1] = 6;
  loopDataTwo[2] = 12;
  loopDataTwo[3] = 24;
  loopDataTwo[4] = 48;
  loopDataTwo[5] = 96;
  loopDataTwo[6] = 192;
  loopDataTwo[7] = 128;
  loopDataTwo[8] = 1;
  loopDataTwo[9] = 1;

  loopDataThree[0] = 8;
  loopDataThree[1] = 24;
  loopDataThree[2] = 48;
  loopDataThree[3] = 96;
  loopDataThree[4] = 192;
  loopDataThree[5] = 128;
  loopDataThree[6] = 0;
  loopDataThree[7] = 1;
  loopDataThree[8] = 3;
  loopDataThree[9] = 6;

  loopDataFour[0] = 4;
  loopDataFour[1] = 12;
  loopDataFour[2] = 24;
  loopDataFour[3] = 48;
  loopDataFour[4] = 224;
  loopDataFour[5] = 193;
  loopDataFour[6] = 3;
  loopDataFour[7] = 2;
  loopDataFour[8] = 2;
  loopDataFour[9] = 2;

  loopDataFive[0] = 0;
  loopDataFive[1] = 0;
  loopDataFive[2] = 0;
  loopDataFive[3] = 0;
  loopDataFive[4] = 0;
  loopDataFive[5] = 1;
  loopDataFive[6] = 3;
  loopDataFive[7] = 6;
  loopDataFive[8] = 12;
  loopDataFive[9] = 8;

  waveDataOne[0] = 56;
  waveDataOne[1] = 124;
  waveDataOne[2] = 198;
  waveDataOne[3] = 131;
  waveDataOne[4] = 1;
  waveDataOne[5] = 0;
  waveDataOne[6] = 0;
  waveDataOne[7] = 0;
  waveDataOne[8] = 0;
  waveDataOne[9] = 0;
  waveDataOne[10] = 0;
  waveDataOne[11] = 0;
  waveDataOne[12] = 0;
  waveDataOne[13] = 0;
  waveDataOne[14] = 0;
  waveDataOne[15] = 0;

  waveDataTwo[0] = 0;
  waveDataTwo[1] = 0;
  waveDataTwo[2] = 0;
  waveDataTwo[3] = 1;
  waveDataTwo[4] = 25;
  waveDataTwo[5] = 60;
  waveDataTwo[6] = 102;
  waveDataTwo[7] = 194;
  waveDataTwo[8] = 128;
  waveDataTwo[9] = 0;
  waveDataTwo[10] = 0;
  waveDataTwo[11] = 0;
  waveDataTwo[12] = 0;
  waveDataTwo[13] = 0;
  waveDataTwo[14] = 0;
  waveDataTwo[15] = 0;

  waveDataThree[0] = 0;
  waveDataThree[1] = 0;
  waveDataThree[2] = 0;
  waveDataThree[3] = 0;
  waveDataThree[4] = 0;
  waveDataThree[5] = 0;
  waveDataThree[6] = 0;
  waveDataThree[7] = 4;
  waveDataThree[8] = 7;
  waveDataThree[9] = 251;
  waveDataThree[10] = 248;
  waveDataThree[11] = 0;
  waveDataThree[12] = 0;
  waveDataThree[13] = 0;
  waveDataThree[14] = 0;
  waveDataThree[15] = 0;

  waveDataFour[0] = 0;
  waveDataFour[1] = 0;
  waveDataFour[2] = 0;
  waveDataFour[3] = 0;
  waveDataFour[4] = 0;
  waveDataFour[5] = 0;
  waveDataFour[6] = 0;
  waveDataFour[7] = 0;
  waveDataFour[8] = 0;
  waveDataFour[9] = 0;
  waveDataFour[10] = 1;
  waveDataFour[11] = 3;
  waveDataFour[12] = 114;
  waveDataFour[13] = 248;
  waveDataFour[14] = 140;
  waveDataFour[15] = 4;

  waveDataFive[0] = 0;
  waveDataFive[1] = 0;
  waveDataFive[2] = 0;
  waveDataFive[3] = 0;
  waveDataFive[4] = 0;
  waveDataFive[5] = 0;
  waveDataFive[6] = 0;
  waveDataFive[7] = 0;
  waveDataFive[8] = 0;
  waveDataFive[9] = 0;
  waveDataFive[10] = 0;
  waveDataFive[11] = 0;
  waveDataFive[12] = 3;
  waveDataFive[13] = 4;
  waveDataFive[14] = 12;
  waveDataFive[15] = 8;
}

void loop() {
  //Read button states and analog value
  blinkBtnState = digitalRead(blinkBtn);
  waveBtnState = digitalRead(waveBtn);
  loopBtnState = digitalRead(loopBtn);
  masterState = digitalRead(masterSwitch);
  speedValue = analogRead(speedPot);
  
  speedValue = speedValue / 3;
  Serial.println(speedValue);
  //Prevents lights from flashing too fast to avoid epilepsy
  if(speedValue < 30)
    speedValue = 30;

  //Checks if button is clicked and then changes mode appropriately
  if(masterState == LOW)
  {
    master = 1;
  }
  else
  {
    master = 0;
    turnOff();
    digitalWrite(reset, LOW); 
  }
  if(blinkBtnState == LOW)
  {
    mode = 1;
  }
  if(waveBtnState == LOW)
  {
    mode = 2;
  }
  if(loopBtnState == LOW)
  {
    mode = 3;
  }

  //Beeps at a certain frequency when enclosure is rotated too much
  if(myIMU.readFloatAccelX() > 0.5 || myIMU.readFloatAccelX() < -0.5 || myIMU.readFloatAccelY() > 0.5 || myIMU.readFloatAccelY() < -0.5)
  {
    tone(buzzer,350,100);
  }

  //Runs led modes based on current mode
  if(mode == 1 && master == 1)
  {
    if(speedValue < 150)
      speedValue = 150;
    blinkLeds(speedValue);
  }
  if(mode == 2 && master == 1)
  {
    colorWave(speedValue);
  }
  if(mode == 3 && master == 1)
  {
    loopLetters(speedValue);
  }
}

//LEDs light up by columns, two at a time from left to right
void colorWave(int d)
{
    if(j==16)
      j=0;
    waveOne = waveDataOne[j];
    waveTwo = waveDataTwo[j];
    waveThree = waveDataThree[j];
    waveFour = waveDataFour[j];
    waveFive = waveDataFive[j];
    //ground latchPin and hold low for as long as you are transmitting
    digitalWrite(latchPin, 0);
    //move 'em out
    shiftOut(dataPin, clockPin, waveFive);
    shiftOut(dataPin, clockPin, waveFour);
    shiftOut(dataPin, clockPin, waveThree);
    shiftOut(dataPin, clockPin, waveTwo);
    shiftOut(dataPin, clockPin, waveOne);
    //return the latch pin high to signal chip that it 
    //no longer needs to listen for information
    digitalWrite(latchPin, 1);
    j++;
    delay(d);
}

//LEDs make a trail and loop each letter individually
void loopLetters(int d)
{
  if(j==10)
      j=0;
    loopOne = loopDataOne[j];
    loopTwo = loopDataTwo[j];
    loopThree = loopDataThree[j];
    loopFour = loopDataFour[j];
    loopFive = loopDataFive[j];
    //ground latchPin and hold low for as long as you are transmitting
    digitalWrite(latchPin, 0);
    //move 'em out
    shiftOut(dataPin, clockPin, loopFive);
    shiftOut(dataPin, clockPin, loopFour);
    shiftOut(dataPin, clockPin, loopThree);
    shiftOut(dataPin, clockPin, loopTwo);
    shiftOut(dataPin, clockPin, loopOne);
    //return the latch pin high to signal chip that it 
    //no longer needs to listen for information
    digitalWrite(latchPin, 1);
    j++;
    delay(d);
}

void turnOff()
{
  digitalWrite(latchPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  digitalWrite(latchPin, 1);
}

//blinks the whole register based on the number of times you want to 
//blink "n" and the pause between them "d"
//starts with a moment of darkness to make sure the first blink
//has its full visual effect.
void blinkLeds(int d) 
{
  digitalWrite(latchPin, 0);
  shiftOut(dataPin, clockPin, 255);
  shiftOut(dataPin, clockPin, 255);
  shiftOut(dataPin, clockPin, 255);
  shiftOut(dataPin, clockPin, 255);
  shiftOut(dataPin, clockPin, 255);
  digitalWrite(latchPin, 1);
  delay(d);
  digitalWrite(latchPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  digitalWrite(latchPin, 1);
  delay(d);
}

// the heart of the program
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) 
{
  // This shifts 8 bits out MSB first, 
  //on the rising edge of the clock,
  //clock idles low

  //internal function setup
  int i=0;
  int pinState;
  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, OUTPUT);

  //clear everything out just in case to
  //prepare shift register for bit shifting
  digitalWrite(myDataPin, 0);
  digitalWrite(myClockPin, 0);

  //for each bit in the byte myDataOut�
  //NOTICE THAT WE ARE COUNTING DOWN in our for loop
  //This means that %00000001 or "1" will go through such
  //that it will be pin Q0 that lights. 
  for (i=7; i>=0; i--)  
  {
    digitalWrite(myClockPin, 0);

    //if the value passed to myDataOut and a bitmask result 
    // true then... so if we are at i=6 and our value is
    // %11010100 it would the code compares it to %01000000 
    // and proceeds to set pinState to 1.
    if ( myDataOut & (1<<i) ) 
    {
      pinState= 1;
    }
    else 
    {  
      pinState= 0;
    }

    //Sets the pin to HIGH or LOW depending on pinState
    digitalWrite(myDataPin, pinState);
    //register shifts bits on upstroke of clock pin  
    digitalWrite(myClockPin, 1);
    //zero the data pin after shift to prevent bleed through
    digitalWrite(myDataPin, 0);
  }
  //stop shifting
  digitalWrite(myClockPin, 0);
} 

Custom parts and enclosures

Interactive LED Box
This is the enclosure file cut on wood using a laser cutter
childrens_toy_yGSUgNJB2i.ai

Schematics

Wiring Diagram for Shift Registers
Daisy chain smbyunozxr

Comments

Similar projects you might like

Controlling LED Brightness Using Bolt and Arduino

Project tutorial by Devashish Gupta

  • 2,872 views
  • 8 comments
  • 19 respects

Interactive 4x4x4 LED cube

Project tutorial by Tong Xin Hua

  • 2,636 views
  • 0 comments
  • 0 respects

IoTrix (Smart Advertisement LED Board)

Project tutorial by Ravi Parmar

  • 2,940 views
  • 0 comments
  • 23 respects

LED Cube

Project tutorial by Praditha Alwis

  • 8,935 views
  • 0 comments
  • 16 respects

LED Matrix Display Badge

Project tutorial by Team FabLabAQ

  • 3,482 views
  • 3 comments
  • 19 respects

Bluetooth control led with lcd led status display real time.

Project tutorial by Youssef Sabaa

  • 26,582 views
  • 4 comments
  • 51 respects
Add projectSign up / Login