Project tutorial
Toddler's Drum Kit Toy - PCL Project 1 - Group 3

Toddler's Drum Kit Toy - PCL Project 1 - Group 3

This toy consists of 4 buttons, 4 LEDs 5 potentiometers and 1 speaker. Toddlers can turn, slide and push to change the lights & sounds.

  • 1,246 views
  • 0 comments
  • 3 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

Overview

In this project we build a children's toy that consists of potentiometers, buttons, lights, and sounds. We started by researching what toddlers are capable of and what toys are currently on the market.

Inspiration

We were inspired by other music making toys on the market, as well as DJ sound boards. We added RGB LEDs and different potentiometers to make ours more interactive.

Designs and Sketches

To design our project, we used Tinkercad to help us wire and test code. As we were wiring our project we noticed that there weren't enough pins on one Sparkfun Red Board for all of our components. We didn't have the budget to buy a bigger board, so we decided to use one board for LEDs and potentiometers, and another for buttons and sound.

Prototyping

While we waited for the materials to arrive we worked on and tested our code.

Trouble Shooting

The hardest part of this project was the assembly. After soldering wires to all of our components we found that it was difficult to make sure all the wires are connected.

Once everything was moved into the container the slide potentiometer was no longer working. We didn't have time to fix it so we decided to cut it out of our project. If we were to do this project again we would add the slide potentiometer and use it to change the tone of the buttons.

Finished Product

Our final toy consisted of 4 knob potentiometers, 4 RGB LEDs, 4 pushbuttons, and 1 piezo buzzer. The potentiometers control the color of the corresponding LED, and each button produces a different tone.

What we learned

We made the mistake of ordering Common Anode LEDs, through this mistake we learned the difference between Common Anode and Common Cathode.

  • A RGB Common Anode LED should have it's longest leg (leg 2) connected to the 5V pin on your Arduino (Current sink)
  • A RGB Common Cathode LED should have it's longest leg (leg 2) connected to the ground pin on your Arduino (Current source)

Anything we would change next time

We realized too late that our Sparkfun Redboard didn't have enough pins for all of our components. To fix this issue we used the Sparkfun Redboard for the buttons and piezo, and an Arduino UNO for the potentiometers and LEDs. If we were to do this project again we would use a different microcontroller with more pins

We would also add the slide potentiometer that we intended to add, but didn't have the time to do so. The slide potentiometer could be used to change the tone of the buttons.

Code

Lights & Knob PotentiometersC/C++
Used with Arduino Uno
//LED Code for Uno

const int analogPin = A0;//the analog input pin attach to analog pin A0
const int LEDRed = 11;//the led attach to pin 9
const int LEDGreen = 13;
const int LEDBlue = 12;
int inputValue = 0;//variable to store the value coming from sensor
int outputValue = 0;//variable to store the output value

const int analogPin2 = A1;//the analog input pin attach to analog pin A0
const int LEDRed2 = 8;//the led attach to pin 9
const int LEDGreen2 = 10;
const int LEDBlue2 = 9;
int inputValue2 = 0;//variable to store the value coming from sensor
int outputValue2 = 0;//variable to store the output value


const int analogPin3 = A2;//the analog input pin attach to analog pin A0
const int LEDRed3 = 5;//the led attach to pin 9
const int LEDGreen3= 7;
const int LEDBlue3 = 6;
int inputValue3 = 0;//variable to store the value coming from sensor
int outputValue3 = 0;//variable to store the output value


const int analogPin4 = A3;//the analog input pin attach to analog pin A0
const int LEDRed4 = 2;//the led attach to pin 9
const int LEDGreen4 = 4;
const int LEDBlue4 = 3;
int inputValue4 = 0;//variable to store the value coming from sensor
int outputValue4 = 0;//variable to store the output value


void setup(){
  Serial.begin(9600);
  pinMode(LEDRed,OUTPUT);
  pinMode(LEDGreen,OUTPUT);
  pinMode(LEDBlue,OUTPUT);  

  pinMode(LEDRed2,OUTPUT);
  pinMode(LEDGreen2,OUTPUT);
  pinMode(LEDBlue2,OUTPUT);  
  
  pinMode(LEDRed3,OUTPUT);
  pinMode(LEDGreen3,OUTPUT);
  pinMode(LEDBlue3,OUTPUT); 
  
  pinMode(LEDRed4,OUTPUT);
  pinMode(LEDGreen4,OUTPUT);
  pinMode(LEDBlue4,OUTPUT); 
}

void loop(){

  /////////////1//////////////
  inputValue = analogRead(analogPin);//read the value from the sensor
outputValue = map(inputValue,0,1023,0,255);//Convert from 0-1023 proportional to the number of a number of from 0 to 255
 
if (outputValue < 100) //red
  {
  analogWrite(LEDRed,255);
   analogWrite(LEDGreen,0);
   analogWrite(LEDBlue,0); 
  }
  else if (outputValue < 110)//red orange
  {
   analogWrite(LEDRed,255);
   analogWrite(LEDGreen,60);
   analogWrite(LEDBlue,0); 
  }
  else if (outputValue < 120)//orange
  {
   analogWrite(LEDRed,255);
   analogWrite(LEDGreen,123);
   analogWrite(LEDBlue,0); 
  }
  else if (outputValue < 130)//orange yellow
  {
   analogWrite(LEDRed,255);
   analogWrite(LEDGreen,180);
   analogWrite(LEDBlue,0); 
  }
  else if (outputValue < 140)//yellow
  {
   analogWrite(LEDRed,255);
   analogWrite(LEDGreen,246);
   analogWrite(LEDBlue,0);
  }
  else if (outputValue < 150)//yellow green
  {
   analogWrite(LEDRed,220);
   analogWrite(LEDGreen,244);
   analogWrite(LEDBlue,66);
  }
  else if (outputValue < 160)//green
  {
    analogWrite(LEDRed,0);
   analogWrite(LEDGreen,255);
   analogWrite(LEDBlue,0);
  }
  else if (outputValue < 170)//green blue
  {
    analogWrite(LEDRed,66);
   analogWrite(LEDGreen,244);
   analogWrite(LEDBlue,161);
  }
  else if (outputValue < 180)//blue
  {
   analogWrite(LEDRed,0);
   analogWrite(LEDGreen,255);
   analogWrite(LEDBlue,250);
  }
   else if (outputValue < 190)//blue cyan
  {
   analogWrite(LEDRed,66);
   analogWrite(LEDGreen,164);
   analogWrite(LEDBlue,244);
  }
  else if (outputValue < 200)//cyan
  {
   analogWrite(LEDRed,0);
   analogWrite(LEDGreen,0);
   analogWrite(LEDBlue,255);
  }
   else if (outputValue < 210)//cyan purple
  {
   analogWrite(LEDRed,140);
   analogWrite(LEDGreen,66);
   analogWrite(LEDBlue,255);
  }
  else if (outputValue < 220)//purple
  {
   analogWrite(LEDRed,182);
   analogWrite(LEDGreen,0);
   analogWrite(LEDBlue,255);
  }
  else if (outputValue < 230)//pink purple
  {
   analogWrite(LEDRed,219);
   analogWrite(LEDGreen,0);
   analogWrite(LEDBlue,225);
  }
  else if (outputValue < 240)//pink 
  {
   analogWrite(LEDRed,255);
   analogWrite(LEDGreen,0);
   analogWrite(LEDBlue,208);
  }
  
/////////////2//////////////
inputValue2 = analogRead(analogPin2);//read the value from the sensor
outputValue2 = map(inputValue2,0,1023,0,255);//Convert from 0-1023 proportional to the number of a number of from 0 to 255

 if (outputValue2 < 100) //red
  {
  analogWrite(LEDRed2,255);
   analogWrite(LEDGreen2,0);
   analogWrite(LEDBlue2,0); 
  }
  else if (outputValue2 < 110)//red orange
  {
   analogWrite(LEDRed2,255);
   analogWrite(LEDGreen2,60);
   analogWrite(LEDBlue2,0); 
  }
  else if (outputValue2 < 120)//orange
  {
   analogWrite(LEDRed2,255);
   analogWrite(LEDGreen2,123);
   analogWrite(LEDBlue2,0); 
  }
  else if (outputValue2 < 130)//orange yellow
  {
   analogWrite(LEDRed2,255);
   analogWrite(LEDGreen2,180);
   analogWrite(LEDBlue2,0); 
  }
  else if (outputValue2 < 140)//yellow
  {
   analogWrite(LEDRed2,255);
   analogWrite(LEDGreen2,246);
   analogWrite(LEDBlue2,0);
  }
  else if (outputValue2 < 150)//yellow green
  {
   analogWrite(LEDRed2,220);
   analogWrite(LEDGreen2,244);
   analogWrite(LEDBlue2,66);
  }
  else if (outputValue2 < 160)//green
  {
    analogWrite(LEDRed2,0);
   analogWrite(LEDGreen2,255);
   analogWrite(LEDBlue2,0);
  }
  else if (outputValue2 < 170)//green blue
  {
    analogWrite(LEDRed2,66);
   analogWrite(LEDGreen2,244);
   analogWrite(LEDBlue2,161);
  }
  else if (outputValue2 < 180)//blue
  {
   analogWrite(LEDRed2,0);
   analogWrite(LEDGreen2,255);
   analogWrite(LEDBlue2,250);
  }
   else if (outputValue2 < 190)//blue cyan
  {
   analogWrite(LEDRed2,66);
   analogWrite(LEDGreen2,164);
   analogWrite(LEDBlue2,244);
  }
  else if (outputValue2 < 200)//cyan
  {
   analogWrite(LEDRed2,0);
   analogWrite(LEDGreen2,0);
   analogWrite(LEDBlue2,255);
  }
   else if (outputValue2 < 210)//cyan purple
  {
   analogWrite(LEDRed2,140);
   analogWrite(LEDGreen2,66);
   analogWrite(LEDBlue2,255);
  }
  else if (outputValue2 < 220)//purple
  {
   analogWrite(LEDRed2,182);
   analogWrite(LEDGreen2,0);
   analogWrite(LEDBlue2,255);
  }
  else if (outputValue2 < 230)//pink purple
  {
   analogWrite(LEDRed2,219);
   analogWrite(LEDGreen2,0);
   analogWrite(LEDBlue2,225);
  }
  else if (outputValue2 < 240)//pink 
  {
   analogWrite(LEDRed2,255);
   analogWrite(LEDGreen2,0);
   analogWrite(LEDBlue2,208);
  }
/////////////3//////////////
  inputValue3 = analogRead(analogPin3);//read the value from the sensor
outputValue3 = map(inputValue3,0,1023,0,255);//Convert from 0-1023 proportional to the number of a number of from 0 to 255
 if (outputValue3 < 100) //red
  {
  analogWrite(LEDRed3,255);
   analogWrite(LEDGreen3,0);
   analogWrite(LEDBlue3,0); 
  }
  else if (outputValue3 < 110)//red orange
  {
   analogWrite(LEDRed3,255);
   analogWrite(LEDGreen3,60);
   analogWrite(LEDBlue3,0); 
  }
  else if (outputValue3 < 120)//orange
  {
   analogWrite(LEDRed3,255);
   analogWrite(LEDGreen3,123);
   analogWrite(LEDBlue3,0); 
  }
  else if (outputValue3 < 130)//orange yellow
  {
   analogWrite(LEDRed3,255);
   analogWrite(LEDGreen3,180);
   analogWrite(LEDBlue3,0); 
  }
  else if (outputValue3 < 140)//yellow
  {
   analogWrite(LEDRed3,255);
   analogWrite(LEDGreen3,246);
   analogWrite(LEDBlue3,0);
  }
  else if (outputValue3 < 150)//yellow green
  {
   analogWrite(LEDRed3,220);
   analogWrite(LEDGreen3,244);
   analogWrite(LEDBlue3,66);
  }
  else if (outputValue3 < 160)//green
  {
    analogWrite(LEDRed3,0);
   analogWrite(LEDGreen3,255);
   analogWrite(LEDBlue3,0);
  }
  else if (outputValue3 < 170)//green blue
  {
    analogWrite(LEDRed3,66);
   analogWrite(LEDGreen3,244);
   analogWrite(LEDBlue3,161);
  }
  else if (outputValue3 < 180)//blue
  {
   analogWrite(LEDRed3,0);
   analogWrite(LEDGreen3,255);
   analogWrite(LEDBlue3,250);
  }
   else if (outputValue3 < 190)//blue cyan
  {
   analogWrite(LEDRed3,66);
   analogWrite(LEDGreen3,164);
   analogWrite(LEDBlue3,244);
  }
  else if (outputValue3 < 200)//cyan
  {
   analogWrite(LEDRed3,0);
   analogWrite(LEDGreen3,0);
   analogWrite(LEDBlue3,255);
  }
   else if (outputValue3 < 210)//cyan purple
  {
   analogWrite(LEDRed3,140);
   analogWrite(LEDGreen3,66);
   analogWrite(LEDBlue3,255);
  }
  else if (outputValue3 < 220)//purple
  {
   analogWrite(LEDRed3,182);
   analogWrite(LEDGreen3,0);
   analogWrite(LEDBlue3,255);
  }
  else if (outputValue3 < 230)//pink purple
  {
   analogWrite(LEDRed3,219);
   analogWrite(LEDGreen3,0);
   analogWrite(LEDBlue3,225);
  }
  else if (outputValue3 < 240)//pink 
  {
   analogWrite(LEDRed3,255);
   analogWrite(LEDGreen3,0);
   analogWrite(LEDBlue3,208);
  }
 
  

/////////////4//////////////
  inputValue4 = analogRead(analogPin4);//read the value from the sensor
outputValue4 = map(inputValue4,0,1023,0,255);//Convert from 0-1023 proportional to the number of a number of from 0 to 255
 
 if (outputValue4 < 100) //red
  {
  analogWrite(LEDRed4,255);
   analogWrite(LEDGreen4,0);
   analogWrite(LEDBlue4,0); 
  }
  else if (outputValue4 < 110)//red orange
  {
   analogWrite(LEDRed4,255);
   analogWrite(LEDGreen4,60);
   analogWrite(LEDBlue4,0); 
  }
  else if (outputValue4 < 120)//orange
  {
   analogWrite(LEDRed4,255);
   analogWrite(LEDGreen4,123);
   analogWrite(LEDBlue4,0); 
  }
  else if (outputValue4 < 130)//orange yellow
  {
   analogWrite(LEDRed4,255);
   analogWrite(LEDGreen4,180);
   analogWrite(LEDBlue4,0); 
  }
  else if (outputValue4 < 140)//yellow
  {
   analogWrite(LEDRed4,255);
   analogWrite(LEDGreen4,246);
   analogWrite(LEDBlue4,0);
  }
  else if (outputValue4 < 150)//yellow green
  {
   analogWrite(LEDRed4,220);
   analogWrite(LEDGreen4,244);
   analogWrite(LEDBlue4,66);
  }
  else if (outputValue4 < 160)//green
  {
    analogWrite(LEDRed4,0);
   analogWrite(LEDGreen4,255);
   analogWrite(LEDBlue4,0);
  }
  else if (outputValue4 < 170)//green blue
  {
    analogWrite(LEDRed4,66);
   analogWrite(LEDGreen4,244);
   analogWrite(LEDBlue4,161);
  }
  else if (outputValue4 < 180)//blue
  {
   analogWrite(LEDRed4,0);
   analogWrite(LEDGreen4,255);
   analogWrite(LEDBlue4,250);
  }
   else if (outputValue4 < 190)//blue cyan
  {
   analogWrite(LEDRed4,66);
   analogWrite(LEDGreen4,164);
   analogWrite(LEDBlue4,244);
  }
  else if (outputValue4 < 200)//cyan
  {
   analogWrite(LEDRed4,0);
   analogWrite(LEDGreen4,0);
   analogWrite(LEDBlue4,255);
  }
   else if (outputValue4 < 210)//cyan purple
  {
   analogWrite(LEDRed4,140);
   analogWrite(LEDGreen4,66);
   analogWrite(LEDBlue4,255);
  }
  else if (outputValue4 < 220)//purple
  {
   analogWrite(LEDRed4,182);
   analogWrite(LEDGreen4,0);
   analogWrite(LEDBlue4,255);
  }
  else if (outputValue4 < 230)//pink purple
  {
   analogWrite(LEDRed4,219);
   analogWrite(LEDGreen4,0);
   analogWrite(LEDBlue4,225);
  }
  else if (outputValue4 < 240)//pink 
  {
   analogWrite(LEDRed4,255);
   analogWrite(LEDGreen4,0);
   analogWrite(LEDBlue4,208);
  }
  

    
}
Button, Buzzer, and Slide PotentiometerC/C++
Used with Sparkfun RedBoard
//Button Sound Code for Uno

int val;
int sensorPin=0;
int Buzzer1 = 9;

const int buttonPin2 = 2;
const int buttonPin3 = 3;
const int buttonPin4 = 4;
const int buttonPin5 = 5;

// the number of the pushbutton pin
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int buttonState5 = 0;

void setup() {
  // initialize the piezo as output:
  pinMode(Buzzer1, OUTPUT);  
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin2, INPUT);  
  pinMode(buttonPin3, INPUT); 
  pinMode(buttonPin4, INPUT); 
  pinMode(buttonPin5, INPUT); 
}

void loop(){
  
  // read the state of the pushbutton value:
  buttonState2 = digitalRead(buttonPin2);
  buttonState3 = digitalRead(buttonPin3);
  buttonState4 = digitalRead(buttonPin4);
  buttonState5 = digitalRead(buttonPin5);
  
  val=map(analogRead(sensorPin),0,1024,0,900);
  Serial.println(val);


//////////////tone(buzzer,note,duration)
  if (val<250) ///////////////////////////////setting 1
 {                     
    if (buttonState2 == HIGH) 
    {     
      tone(Buzzer1, 25,200);
    }  
    if (buttonState3 == HIGH) 
    {  
      tone(Buzzer1,50,200);
    }
    if (buttonState4 == HIGH) 
    {
      tone(Buzzer1,75,200);
    }
    if (buttonState5 == HIGH) 
    {    
      tone(Buzzer1,100,200);
    } 
 } 
 else if (val<500) //////////////////////setting 2
 {                     
    if (buttonState2 == HIGH) 
    {     
      tone(Buzzer1,125,200);
    }  
    if (buttonState3 == HIGH) 
    {  
      tone(Buzzer1,150,200);
    }
    if (buttonState4 == HIGH) 
    {
      tone(Buzzer1,175,200);
    }
    if (buttonState5 == HIGH) 
    {    
      tone(Buzzer1,200,200);
    } 
 } 
 else if (val<750)  ////////////////////setting 3
 {                     
    if (buttonState2 == HIGH) 
    {     
      tone(Buzzer1,225,200);///////////
    }  
    if (buttonState3 == HIGH) 
    {  
      tone(Buzzer1,250,200);
    }
    if (buttonState4 == HIGH) 
    {
      tone(Buzzer1,275,200);
    }
    if (buttonState5 == HIGH) 
    {    
      tone(Buzzer1,300,200);
    } 
 } 
 else if (val<1023) /////////////////////setting 4
 {                     
    if (buttonState2 == HIGH) 
    {     
      tone(Buzzer1,325,200);
    }  
    if (buttonState3 == HIGH) 
    {  
      tone(Buzzer1,350,200);
    }
    if (buttonState4 == HIGH) 
    {
      tone(Buzzer1,375,200);
    }
    if (buttonState5 == HIGH) 
    {    
      tone(Buzzer1,400,200);
    } 
 } 
  
}

Schematics

Lights & Knob Potentiometers
Gggggggggggggggggg nr0aatizxm
Button, Buzzer, and Slide Potentiometer
Fffffffffffffffffffffffffffffffffffffffffff ubh8k0q7ce

Comments

Similar projects you might like

Interactive Toddler Music Box Toy

Project tutorial by Christopher Monreal and Nick Udell

  • 1,226 views
  • 0 comments
  • 2 respects

Interactive Children's Jack-In-The-Box

Project tutorial by Team 10

  • 944 views
  • 0 comments
  • 4 respects

Minimal MIDI Drum Kit with 3D Printer

Project tutorial by ryokosaka

  • 14,739 views
  • 1 comment
  • 38 respects

ATmega Alien Themed Slot Machine

Project tutorial by Dan Murphy

  • 2,269 views
  • 6 comments
  • 25 respects

Handheld Infinity Kaleidoscope Group Kit

Project tutorial by Lucas Ainsworth

  • 9,680 views
  • 4 comments
  • 67 respects

The Magnetic Field and RGB Tester

Project tutorial by Kutluhan Aktar

  • 4,600 views
  • 0 comments
  • 17 respects
Add projectSign up / Login