Project showcase

Xmas musical robot © GPL3+

A musical robot for Christmas

  • 221 views
  • 0 comments
  • 2 respects

Components and supplies

About this project

Made for a school contest.

Code

Arduino codeArduino
#define NOTE_G3 392
#define NOTE_A3 440
#define NOTE_B3 494
#define NOTE_C4 523
#define NOTE_D4 587
#define NOTE_E4 659
#define NOTE_F4 699
#define NOTE_G4 784
#define NOTE_A4 880

void setup() {
pinMode(6,OUTPUT);  // Tone
pinMode(7,OUTPUT);  // Red
pinMode(8,OUTPUT);  // Green
pinMode(9,INPUT);   // Switch
pinMode(5,OUTPUT);  // Blue
digitalWrite(9,HIGH);
}

unsigned int notes[109][2]={
  {NOTE_E4,1},{NOTE_E4,1},{NOTE_E4,2},{NOTE_E4,1},{NOTE_E4,1},{NOTE_E4,2},{NOTE_E4,1},{NOTE_G4,1},{NOTE_C4,1},{NOTE_D4,1},{NOTE_E4,4},
  {NOTE_F4,1},{NOTE_F4,1},{NOTE_F4,2},{NOTE_E4,1},{NOTE_E4,1},{NOTE_E4,2},{NOTE_E4,1},{NOTE_D4,1},{NOTE_D4,1},{NOTE_E4,1},{NOTE_D4,2},{NOTE_G4,2},
  {NOTE_E4,1},{NOTE_E4,1},{NOTE_E4,2},{NOTE_E4,1},{NOTE_E4,1},{NOTE_E4,2},{NOTE_E4,1},{NOTE_G4,1},{NOTE_C4,1},{NOTE_D4,1},{NOTE_E4,4},
  {NOTE_F4,1},{NOTE_F4,1},{NOTE_F4,2},{NOTE_E4,1},{NOTE_E4,1},{NOTE_E4,2},{NOTE_G4,1},{NOTE_G4,1},{NOTE_F4,1},{NOTE_D4,1},{NOTE_C4,4},
  {NOTE_G3,1},{NOTE_E4,1},{NOTE_D4,1},{NOTE_C4,1},{NOTE_G3,2},{NOTE_G3,1},{NOTE_E4,1},{NOTE_D4,1},{NOTE_C4,1},{NOTE_A3,2},
  {NOTE_A3,1},{NOTE_F4,1},{NOTE_E4,1},{NOTE_D4,1},{NOTE_B3,2},{NOTE_G4,1},{NOTE_G4,1},{NOTE_F4,1},{NOTE_D4,1},{NOTE_E4,2},
  {NOTE_G3,1},{NOTE_E4,1},{NOTE_D4,1},{NOTE_C4,1},{NOTE_G3,2},{NOTE_G3,1},{NOTE_E4,1},{NOTE_D4,1},{NOTE_C4,1},{NOTE_A3,2},
  {NOTE_A3,1},{NOTE_F4,1},{NOTE_E4,1},{NOTE_D4,1},{NOTE_G4,1},{NOTE_G4,1},{NOTE_G4,2},{NOTE_A4,1},{NOTE_G4,1},{NOTE_F4,1},{NOTE_D4,1},{NOTE_C4,4},
  {NOTE_E4,1},{NOTE_E4,1},{NOTE_E4,2},{NOTE_E4,1},{NOTE_E4,1},{NOTE_E4,2},{NOTE_E4,1},{NOTE_G4,1},{NOTE_C4,1},{NOTE_D4,1},{NOTE_E4,4},
  {NOTE_F4,1},{NOTE_F4,1},{NOTE_F4,2},{NOTE_E4,1},{NOTE_E4,1},{NOTE_E4,2},{NOTE_G4,1},{NOTE_G4,1},{NOTE_F4,1},{NOTE_D4,1},{NOTE_C4,4},
};

void loop() {
digitalWrite(5,HIGH);
digitalWrite(7,LOW);
digitalWrite(8,LOW);

int A = digitalRead(9);

if (A==0) {
  digitalWrite(5,LOW);  
  digitalWrite(7,HIGH);
  for (int i=0;i<109;i++) {
    tone(6,notes[i][0],notes[i][1]*200);
    delay(notes[i][1]*200+100);
    digitalWrite(7,!digitalRead(7));
    digitalWrite(8,!digitalRead(8));
  }
}
}

Schematics

Schematic
Breadboard
Xmas robot bb qxubm6e3vz
Source file
xmas_robot_k3B7NM16b5.fzz

Comments

Similar projects you might like

Arduino Uno-Based, Easy-to-Build Pet Feeder

Project tutorial by edr1924

  • 1,357 views
  • 2 comments
  • 15 respects

HOW PIR SENSOR WORK

Project tutorial by DIY Partners

  • 1,997 views
  • 6 comments
  • 19 respects

4-Stroke Digital Clock With Arduino

Project tutorial by LAGSILVA

  • 7,234 views
  • 8 comments
  • 30 respects

Dead Bug Valentine

Project tutorial by wrightmac

  • 972 views
  • 0 comments
  • 7 respects

Low Cost Accurate 3D Positioning

Project tutorial by Sumit Aich

  • 4,452 views
  • 5 comments
  • 7 respects
Add projectSign up / Login