Components and supplies
1
Jumper wires (generic)
1
3x4 Analog kepay
1
Mini Metal Speaker w/ Wires - 8 ohm 0.5W
1
Arduino UNO
1
Audio module - MP3-player with MicroSD-card reader, WTV020SD
2
4x4 Analog Keypad
Project description
Code
Learn to spell with the Paw Patrol
arduino
1#include "Arduino.h" 2#include "SoftwareSerial.h" 3#include "DFRobotDFPlayerMini.h" 4 5 6#include <LiquidCrystal_I2C.h>// LCD Library and variables 7LiquidCrystal_I2C lcd(0x27,16,2); 8int lcdLED = 3; // brignes of the LCD 9int bright; // To store the screen brightness 10 11SoftwareSerial mySoftwareSerial(10,11); // RX, TX 12DFRobotDFPlayerMini myDFPlayer; 13void printDetail(uint8_t type, int value); 14 15 16int analogPin0 = A0; // Or any pin you are using 17int analogPin1 = A1; // Or any pin you are using 18int analogPin2 = A2; // Or any pin you are using 19 20String song; 21String dog; 22String mydog; 23 24void setup() 25 { 26 27 // initialize the lcd 28 bright =70;// brignes of the LCD 29 analogWrite(lcdLED, bright);// brignes of the LCD 30 lcd.init(); 31 lcd.backlight(); 32 lcd.setCursor(0,0); 33 lcd.println("Loading... "); 34 35 mySoftwareSerial.begin(9600); 36 Serial.begin(9600); 37 38 if (!myDFPlayer.begin(mySoftwareSerial)) //Use softwareSerial to communicate with mp3. 39 { 40 lcd.println("Unable to begin:"); 41 while(true); 42 } 43 myDFPlayer.setTimeOut(500); //Set serial communictaion time out 500ms 44 myDFPlayer.volume(20); //Set volume value (0~30). 45 myDFPlayer.EQ(DFPLAYER_EQ_NORMAL); 46 myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD); 47 48 lcd.init(); 49 lcd.backlight(); 50 lcd.setCursor(0,0); 51 lcd.println("good to go "); 52 53 } 54 55String PAW (String dog)//PRINT THE NAME OF THE DOG 56 { 57 lcd.init(); 58 lcd.setCursor(0,0); 59 lcd.print(dog); 60 MP3(dog); 61 delay(50); 62 mydog =""; //Zero mydog variable 63 return dog; // return the name of the dog to the main program 64 } 65 66void TYPE( String key, String dog) // print the keyboar imput and compares to the dog name 67 { 68 lcd.setCursor(0,1); 69 lcd.print(mydog); 70 lcd.print(key); 71 if (key == "DEL") //delete last character of the string mydog 72 { 73 int mydoglenght = mydog.length(); // Check the lenght of the string mydog 74 mydoglenght =mydoglenght-1; 75 mydog.remove(mydoglenght, 1); 76 lcd.setCursor(0,1); 77 lcd.print(mydog); 78 lcd.print(" " ); 79 } 80 else{ // Add character to the string mydog 81 mydog= mydog+key; 82 } 83 delay(500); 84 if (mydog == dog) 85 { 86 lcd.print(" MOLT BE" ); // Positive message 87 myDFPlayer.play(35); 88 pinMode(9, HIGH); 89 delay(500); 90 } 91 92 93 94 } 95 96 97 98void MP3 (String mp3Command) 99 { 100 101 102 if (mp3Command == "volumeup") {myDFPlayer.volumeUp();} 103 if (mp3Command == "volumedown"){myDFPlayer.volumeDown();} 104 if (mp3Command == "pause") {myDFPlayer.pause(); } 105 if (mp3Command == "STOP") {myDFPlayer.stop(); } 106 if (mp3Command == "previous") {myDFPlayer.previous(); } 107 if (mp3Command == "next") {myDFPlayer.next();} 108 if (mp3Command == "play") {myDFPlayer.next(); lcd.print("play");} 109 110 // Specific song tracks with the voice of the cartacters 111 if (mp3Command == "PAW PATROL") {myDFPlayer.play(24);} 112 if (mp3Command == "CHASE") {myDFPlayer.play(5);} 113 if (mp3Command == "RUBBLE") {myDFPlayer.play(28);} 114 if (mp3Command == "EVEREST") {myDFPlayer.play(14);} 115 if (mp3Command == "ROCKY") {myDFPlayer.play(10);} 116 if (mp3Command == "ZUMA") {myDFPlayer.play(14);} 117 if (mp3Command == "SKYE") {myDFPlayer.play(31);} 118 if (mp3Command == "TRACKER") {myDFPlayer.play(14);} 119 120 delay(100); 121 } 122 123 124 125void show (String key) //Other functions on the keyboard 126 { 127 128 //Clear Screen 129 if (key == "CLR") 130 { 131 lcd.init(); 132 lcd.setCursor(0,0); 133 } 134 //BRIGHTNES UP Screen 135 if (key == "UP") 136 { 137 bright =bright +10; 138 analogWrite(lcdLED, bright);// brignes of the LCD 139 delay(200); 140 } 141 //BRIGHTNES DOWN Screen 142 if (key == "DOWN") //Clear Screen 143 { 144 bright =bright -10; 145 analogWrite(lcdLED, bright);// brignes of the LCD 146 delay(200); 147 } 148 } 149 150void loop(){ 151 152int val0 = 0; // an auxiliar variable to store the value 153int val1 = 0; // an auxiliar variable to store the value 154int val2 = 0; // an auxiliar variable to store the value 155 156 157 158 char key= (""); 159 160 val0 = analogRead (analogPin0); //4x4 kepay 2 161 if (val0 >= 1020 and val0 <= 1024){dog=PAW("PAW PATROL");}; 162 if (val0 >= 925 and val0 <= 935){dog=PAW("CHASE");}; 163 if (val0 >= 845 and val0 <= 855){dog=PAW("MARSHALL");}; 164 if (val0 >= 785 and val0 <= 795){dog=PAW("RUBBLE");}; 165 if (val0 >= 675 and val0 <= 685){TYPE("Q" ,dog);}; 166 if (val0 >= 630 and val0 <= 640){TYPE("W" ,dog);}; 167 if (val0 >= 595 and val0 <= 605){TYPE("E" ,dog);}; 168 if (val0 >= 560 and val0 <= 570){TYPE("R" ,dog);}; 169 if (val0 >= 500 and val0 <= 510){key = ("OK");myDFPlayer.play(14);}; 170 if (val0 >= 480 and val0 <= 490){TYPE("A" ,dog);}; 171 if (val0 >= 450 and val0 <= 460){TYPE("S" ,dog);}; 172 if (val0 >= 435 and val0 <= 445){TYPE("D" ,dog);}; 173 if (val0 >= 400 and val0 <= 410){MP3("previous");}; 174 if (val0 >= 320 and val0 <= 330){MP3("next");}; 175 if (val0 >= 265 and val0 <= 275){TYPE("Z" ,dog);}; 176 if (val0 >= 233 and val0 <= 243){TYPE("X" ,dog);}; 177 178 val1 = analogRead (analogPin1); //4x4 keypad 1 179 if (val1 >= 1020 and val1 <= 1024){dog=PAW("EVEREST");}; 180 if (val1 >= 925 and val1 <= 935){dog=PAW("ROCKY");}; 181 if (val1 >= 845 and val1 <= 855){dog=PAW("ZUMA");}; 182 if (val1 >= 785 and val1 <= 795){dog=PAW("SKYE");}; 183 if (val1 >= 675 and val1 <= 685){TYPE("T" ,dog);}; 184 if (val1 >= 630 and val1 <= 640){TYPE("Y" ,dog);}; 185 if (val1 >= 595 and val1 <= 605){TYPE("U" ,dog);}; 186 if (val1 >= 560 and val1 <= 570){TYPE("I" ,dog);}; 187 if (val1 >= 500 and val1 <= 510){TYPE("F" ,dog);}; 188 if (val1 >= 480 and val1 <= 490){TYPE("G" ,dog);}; 189 if (val1 >= 450 and val1 <= 460){TYPE("H" ,dog);}; 190 if (val1 >= 435 and val1 <= 445){TYPE("J" ,dog);}; 191 if (val1 >= 400 and val1 <= 410){TYPE("C" ,dog);}; 192 if (val1 >= 320 and val1 <= 330){TYPE("V" ,dog);}; 193 if (val1 >= 265 and val1 <= 275){TYPE("B" ,dog);}; 194 if (val1 >= 233 and val1 <= 243){TYPE("N" ,dog);}; 195 196 val2 = analogRead (analogPin2); //3x4 keypad 197 if (val2 >= 1020 and val2 <= 1024){dog=PAW("TRACKER");}; 198 if (val2 >= 925 and val2<= 935){TYPE("DEL",dog);myDFPlayer.play(6);}; 199 if (val2 >= 845 and val2<= 855){show("CLR");myDFPlayer.play(32);}; 200 if (val2 >= 785 and val2<= 795){TYPE("O" ,dog);}; 201 if (val2 >= 725 and val2 <= 735){TYPE("P",dog);}; 202 if (val2 >= 675 and val2 <=685 ){show("UP");}; 203 if (val2 >= 640 and val2 <= 645){TYPE("K",dog);}; 204 if (val2 >= 600 and val2 <= 610){TYPE("L",dog);}; 205 if (val2 >= 565 and val2<= 575){show("DOWN");}; 206 if (val2 >= 530 and val2 <= 550){TYPE("M",dog);}; 207 if (val2 >= 500 and val2<=515){TYPE(" ",dog);}; 208 if (val2 >= 485 and val2<=495){myDFPlayer.play(17);}; 209} 210
Downloadable files
Paw Patrol game MP3
Paw Patrol game MP3
Paw Patrol game MP3
Paw Patrol game MP3

Paw Patrol game MP3
Paw Patrol game MP3

Paw Patrol game MP3
Paw Patrol game MP3
Comments
Only logged in users can leave comments