Project showcase
Xmas musical robot

Xmas musical robot © GPL3+

A musical robot for Christmas

  • 882 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

MeArm Robot Arm - Your Robot - V1.0

Project tutorial by Benjamin Gray

  • 19,310 views
  • 3 comments
  • 35 respects

Musical Cube

Project showcase by FabLab of Legends

  • 1,773 views
  • 0 comments
  • 1 respect

Smartphone Controlled Arduino 4WD Robot Car

Project in progress by Andriy Baranov

  • 53,245 views
  • 43 comments
  • 98 respects

Android Apps Controlled Arduino Robot Car

by Team platinum

  • 3,594 views
  • 0 comments
  • 16 respects

Arduino Balancing Robot

Project showcase by TEAM DIY

  • 2,287 views
  • 0 comments
  • 7 respects

Motion-Activated Musical Trophy

Project tutorial by Alex Wulff

  • 1,205 views
  • 3 comments
  • 3 respects
Add projectSign up / Login