Isaac WolfSarah Worthington
Published

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.

IntermediateFull instructions provided1,496
Toddler's Drum Kit Toy - PCL Project 1 - Group 3

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
×60
SparkFun RedBoard
SparkFun RedBoard
×1
Breadboard (generic)
Breadboard (generic)
×2
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×4
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
SparkFun knob
×4
Buzzer
Buzzer
×1
SparkFun Buttons
×4
Resistor 330 ohm
Resistor 330 ohm
×16
RGB Diffused Common Cathode
RGB Diffused Common Cathode
×4

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Lights & Knob Potentiometers

Button, Buzzer, and Slide Potentiometer

Code

Lights & Knob Potentiometers

C/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 Potentiometer

C/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);
    } 
 } 
  
}

Credits

Isaac Wolf

Isaac Wolf

1 project • 1 follower
Sarah Worthington

Sarah Worthington

2 projects • 2 followers

Comments