Handmade MKR1000 IoT Christmas show made of colored cardboard paper.
Things used in this project
Hardware components |
||||||
|
× | 1 | ||||
|
× | 1 | ||||
|
× | 1 | ||||
|
× | 10 | ||||
|
× | 4 | ||||
Software apps and online services |
||||||
|
||||||
|
||||||
Hand tools and fabrication machines |
||||||
|
Story
This project was made to be an interactive Christmas decoration, the tree LEDs, music played and the arms of Santa and Elf are all controlled using a phone app created using MIT App Inventor that communicates with the Arduino MKR1000.
First I made a cone shaped paper and painted it green.
Then I have added green cardboard to create leaves of the tree.
Then creating white snow effect using white cardboard.
Soldering LED lines I have made three lines:
Creating the star on top of the tree.
Then I have used gift paper to make gifts under the tree.
I have cut down the shapes of both Santa and Elf and connected servo motors to each arm of them.
Custom parts and enclosures
Schematics
Mini Christmas show
Connection diagram
Code
Mini Christmas Show
Arduino
#include <DFRobotDFPlayerMini.h> //DFPlayer MP3 Module control library#include <Servo.h> //Servo motors control library#include <WiFi101.h> //Wifi library//Defining constants for pins//Santa and Elf Outputsconst int SantaRHand = 0;const int SantaLHand = 1;const int ElfRHand = 2;const int ElfLHand = 3;//Tree Star pinsconst int TreeStar1 = 6;const int TreeStar2 = 7;const int TreeStar3 = 8;//Tree Star Patternsconst int TreeLine1 = 9;const int TreeLine2 = 10;const int TreeLine3 = 11;//Defining variables//Defining Tree Pattern Variableint TreePattern = 1;//Defining MP3 player variableint CurrentSong =1;DFRobotDFPlayerMini myDFPlayer; //Creating DFPlayer objectServo myservo1; //Santa right hand instanceServo myservo2; //Santa left hand instanceServo myservo3; //Elf right hand instance Servo myservo4; //Elf left hand instancechar ssid[] = "YourSSIDName"; // your network SSID (name)char pass[] = "YourSSIDPassword"; // your network password//int keyIndex = 0; // your network key Index number (needed only for WEP)char current_state = 'a';int status = WL_IDLE_STATUS;WiFiServer server(80);void setup() {Serial1.begin(9600); //Initializing serial communication to communicate with DFPlayer module//Set TreeLine Pins to OutputspinMode(TreeLine1, OUTPUT);pinMode(TreeLine2, OUTPUT);pinMode(TreeLine3, OUTPUT);while(!myDFPlayer.begin(Serial1)){} //Wait until DFPlayer startsmyDFPlayer.volume(30); //Setting the volume of DFPlayer 0-30myservo1.attach(SantaRHand); //assigning servo objects to pinsmyservo2.attach(SantaLHand);myservo3.attach(ElfRHand);myservo4.attach(ElfLHand);// attempt to connect to Wifi network:while ( status != WL_CONNECTED) {// Connect to WPA/WPA2 network. Change this line if using open or WEP network:status = WiFi.begin(ssid, pass);// wait 10 seconds for connection:delay(10000);}server.begin(); // start the web server on port 80}void loop() {////////////////////////////////////////////////////////////////////////////////////////////WiFiClient client = server.available(); // listen for incoming clientsif (client) { // if you get a clientString currentLine = ""; // make a String to hold incoming data from the clientwhile (client.connected()) { // loop while the client's connectedif (client.available()) { // if there's bytes to read from the client,char c = client.read(); // read a byte, thenif (c == '\n') { // if the byte is a newline character// if the current line is blank, you got two newline characters in a row.// that's the end of the client HTTP request, so send a response:if (currentLine.length() == 0) {// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)// and a content-type so the client knows what's coming, then a blank line:client.println("HTTP/1.1 200 OK");client.println("Content-type:text/html");client.println();// the content of the HTTP response follows the header://client.print("Click <a href=\"/H\">here</a> turn the LED on pin 6 on<br>");// client.print("Click <a href=\"/L\">here</a> turn the LED on pin 6 off<br>");// client.print("Click <a href=\"/B\">here</a> Blink the LED on pin 6 On and Off<br>");// The HTTP response ends with another blank line:// client.println();// break out of the while loop:break;}else { // if you got a newline, then clear currentLine:currentLine = "";}}else if (c != '\r') { // if you got anything else but a carriage return character,currentLine += c; // add it to the end of the currentLine}// Check to see if the client requestif (currentLine.endsWith("GET /A")) {current_state = 'a'; // Show start requestStartGreeting(); //Jump to greeting function (move hands)myDFPlayer.play(1); //play first song on SD card}if (currentLine.endsWith("GET /B")) {current_state = 'b'; // Show stop request}if (currentLine.endsWith("GET /C")) {StartGreeting(); // Greeting request}//Tree Pattern Change Buttonif (currentLine.endsWith("GET /D")) {TreePattern = 1; //Change tree pattern}if (currentLine.endsWith("GET /E")) {TreePattern = 2; //Change tree pattern}if (currentLine.endsWith("GET /F")) {TreePattern = 3; //Change tree pattern}//Song Change Buttonif (currentLine.endsWith("GET /G")) {myDFPlayer.play(1); //Play First song}if (currentLine.endsWith("GET /H")) {myDFPlayer.play(3); //Play Second Song}if (currentLine.endsWith("GET /I")) {myDFPlayer.pause(); //Stop Playing songs (Pause)}}}// close the connection:client.stop();}////////////////////////////////////////////////////////////////////////////////////////////if (current_state == 'a') { // Show start requestturnOnTree();}if (current_state == 'b') { // Show Stop requestturnOffTree();myDFPlayer.pause();}}void StartGreeting(){myDFPlayer.play(2); //Play greeting soundanalogWrite(TreeStar1,100); //adjust color of the staranalogWrite(TreeStar2,100);analogWrite(TreeStar3,100);digitalWrite(TreeLine1, HIGH); //change tree lines patterndigitalWrite(TreeLine2, HIGH);digitalWrite(TreeLine3, HIGH);delay(6500);SantaElfHi(); //move handsSantaElfHi();SantaElfHi();analogWrite(TreeStar1,100);analogWrite(TreeStar2,100);analogWrite(TreeStar3,100);digitalWrite(TreeLine1, HIGH);digitalWrite(TreeLine2, HIGH);digitalWrite(TreeLine3, HIGH);delay(16000);}void SantaElfHi(){ //Move Santa and Elf Handsmyservo1.write(7);delay(30);myservo2.write(70);delay(30);myservo3.write(7);delay(30);myservo4.write(70);delay(30);analogWrite(TreeStar1,200);analogWrite(TreeStar2,100);analogWrite(TreeStar3,200);digitalWrite(TreeLine1, HIGH);digitalWrite(TreeLine2, HIGH);digitalWrite(TreeLine3, HIGH);delay(1000);analogWrite(TreeStar1,0);analogWrite(TreeStar2,0);analogWrite(TreeStar3,0);digitalWrite(TreeLine1, LOW);digitalWrite(TreeLine2, LOW);digitalWrite(TreeLine3, LOW);myservo1.write(70);delay(30);myservo2.write(7);delay(30);myservo3.write(70);delay(30);myservo4.write(7);delay(30);delay(1000);}void turnOffTree(){//turn off all ledsanalogWrite(TreeStar1,0);analogWrite(TreeStar2,0);analogWrite(TreeStar3,0);digitalWrite(TreeLine1, LOW);digitalWrite(TreeLine2, LOW);digitalWrite(TreeLine3, LOW);}void turnOnTree() {//turn on tree leds with the selected patternswitch (TreePattern) {case 1:analogWrite(TreeStar1,255);digitalWrite(TreeLine1, HIGH);delay(100);analogWrite(TreeStar1,0);analogWrite(TreeStar2,255);digitalWrite(TreeLine2, HIGH);delay(100);analogWrite(TreeStar2,0);analogWrite(TreeStar3,255);digitalWrite(TreeLine3, HIGH);delay(100);analogWrite(TreeStar3,0);digitalWrite(TreeLine1, LOW);digitalWrite(TreeLine2, LOW);digitalWrite(TreeLine3, LOW);delay(100);break;case 2:analogWrite(TreeStar1,255);analogWrite(TreeStar2,0);analogWrite(TreeStar3,255);digitalWrite(TreeLine1, HIGH);digitalWrite(TreeLine2, HIGH);digitalWrite(TreeLine3, HIGH);delay(100);analogWrite(TreeStar1,255);analogWrite(TreeStar2,255);analogWrite(TreeStar3,0);digitalWrite(TreeLine1, LOW);digitalWrite(TreeLine2, LOW);digitalWrite(TreeLine3, LOW);delay(50);analogWrite(TreeStar1,0);analogWrite(TreeStar2,255);analogWrite(TreeStar3,255);digitalWrite(TreeLine1, HIGH);digitalWrite(TreeLine2, HIGH);digitalWrite(TreeLine3, HIGH);delay(100);analogWrite(TreeStar1,255);analogWrite(TreeStar2,200);analogWrite(TreeStar3,100);digitalWrite(TreeLine1, LOW);digitalWrite(TreeLine2, LOW);digitalWrite(TreeLine3, HIGH);delay(100);analogWrite(TreeStar1,255);analogWrite(TreeStar2,0);analogWrite(TreeStar3,255);digitalWrite(TreeLine1, LOW);digitalWrite(TreeLine2, HIGH);digitalWrite(TreeLine3, LOW);delay(100);analogWrite(TreeStar1,255);analogWrite(TreeStar2,0);analogWrite(TreeStar3,0);digitalWrite(TreeLine1, HIGH);digitalWrite(TreeLine2, LOW);digitalWrite(TreeLine3, LOW);delay(100);analogWrite(TreeStar1,0);analogWrite(TreeStar3,255);digitalWrite(TreeLine1, LOW);digitalWrite(TreeLine2, LOW);digitalWrite(TreeLine3, LOW);delay(100);break;case 3:analogWrite(TreeStar1,255);digitalWrite(TreeLine1, HIGH);digitalWrite(TreeLine2, LOW);digitalWrite(TreeLine3, LOW);delay(60);analogWrite(TreeStar1,0);analogWrite(TreeStar2,255);digitalWrite(TreeLine1, LOW);digitalWrite(TreeLine2, HIGH);digitalWrite(TreeLine3, LOW);delay(60);analogWrite(TreeStar2,0);analogWrite(TreeStar3,255);digitalWrite(TreeLine1, LOW);digitalWrite(TreeLine2, LOW);digitalWrite(TreeLine3, HIGH);delay(60);analogWrite(TreeStar1,255);analogWrite(TreeStar3,255);digitalWrite(TreeLine1, LOW);digitalWrite(TreeLine2, HIGH);digitalWrite(TreeLine3, LOW);delay(60);break;}}
Source :Mini Christmas IoT Show!