Components and supplies
DFPlayer - A Mini MP3 Player
Shift Register- Parallel to Serial
Pushbutton Switch, Momentary
Ultrasonic Sensor - HC-SR04 (Generic)
SparkFun 7-Segment Serial Display - Red
Arduino UNO
RGB Diffused Common Cathode
SG90 Micro-servo motor
IR receiver (generic)
Alphanumeric LCD, 16 x 2
PIR Motion Sensor (generic)
Tools and machines
3D Printer (generic)
Apps and platforms
Arduino IDE
Project description
Code
Project files
All of the files for this build
Project files
All of the files for this build
Squid Game Doll Sketch
c_cpp
This will control all of the sensor and the game logic.
1/// CodeMakesItGo Dec 2021 2 3#include <DFPlayerMini_Fast.h> 4#include <FireTimer.h> 5#include <IRremote.h> 6#include <LiquidCrystal_I2C.h> 7#include <SoftwareSerial.h> 8#include <SR04.h> 9#include <Wire.h> 10 11/*-----( Analog Pins )-----*/ 12#define BUTTONS_IN A0 13#define SONAR_TRIG_PIN A1 14#define SONAR_ECHO_PIN A2 15#define MOTION_IN A3 16 17/*-----( Digital Pins )-----*/ 18#define LED_BLUE 13 19#define LED_GREEN 12 20#define LED_RED 11 21#define SEGMENT_DATA 10 // DS 22#define SEGMENT_CLOCK 9 // SHCP 23#define SEGMENT_LATCH 8 // STCP 24#define SEGMENT_1_OUT 7 25#define SEGMENT_2_OUT 6 26#define SEGMENT_3_OUT 5 27#define IR_DIGITAL_IN 4 // IR Remote 28#define SERVO_OUT 3 29#define DFPLAYER_BUSY_IN 2 30 31/*-----( Configuration )-----*/ 32#define TIMER_FREQUENCY 2000 33#define TIMER_MATCH (int)(((16E+6) / (TIMER_FREQUENCY * 64.0)) - 1) 34#define TIMER_2MS ((TIMER_FREQUENCY / 1000) * 2) 35#define VOLUME 30 // 0-30 36#define BETTER_HURRY_S 5 // play clip at 5 seconds left 37#define WIN_PROXIMITY_CM 50 // cm distance for winner 38#define CLOSE_PROXIMITY_CM 100 // cm distance for close to winning 39#define GREEN_LIGHT_MS 3000 // 3 seconds on for green light 40#define RED_LIGHT_MS 5000 // 5 seconds on for green light 41#define WAIT_FOR_STOP_MOTION_MS 5000 // 5 seconds to wait for motion detection to stop 42 43/*-----( Global Variables )-----*/ 44static unsigned int timer_1000ms = 0; 45static unsigned int timer_2ms = 0; 46static unsigned char digit = 0; // digit for 4 segment display 47static int countDown = 60; // Start 1 minute countdown on startup 48static const int sonarVariance = 10; // detect movement if greater than this 49static bool gameInPlay = false; 50static bool faceTree = false; 51static bool remotePlay = false; 52 53// 0 , 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, NULL 54const unsigned char numbers[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x00}; 55 56const char *MenuItems[] = {"Language", "Play Time", "Play Type"}; 57typedef enum 58{ 59 LANGUAGE, 60 PLAYTIME, 61 PLAYTYPE, 62 MENUITEM_COUNT 63} MenuItemTypes; 64 65const char *Languages[] = {"English", "Korean"}; 66typedef enum 67{ 68 ENGLISH, 69 KOREAN, 70 LANUAGE_COUNT 71} LanguageTypes; 72static int language = 0; 73 74const char *PlayTime[] = {"300", "240", "180", "120", "60", "30", "15"}; 75typedef enum 76{ 77 PT300, 78 PT240, 79 PT180, 80 PT120, 81 PT60, 82 PT30, 83 PT15, 84 PLAYTIME_COUNT 85} PlayTimeTypes; 86const int playTimes[] = {300, 240, 180, 120, 60, 30, 15}; 87static int playTime = 0; 88 89const char *PlayType[] = {"Auto", "Remote"}; 90typedef enum 91{ 92 AUTO, 93 REMOTE, 94 PLAYTYPE_COUNT 95} PlayTypeTypes; 96static int playType = 0; 97 98typedef enum 99{ 100 BLACK, 101 RED, 102 GREEN, 103 BLUE, 104 WHITE, 105 YELLOW, 106 PURPLE 107} EyeColors; 108EyeColors eyeColor = BLACK; 109 110typedef enum 111{ 112 WARMUP, 113 WAIT, 114 READY, 115 GREENLIGHT, 116 REDLIGHT, 117 WIN, 118 LOSE 119} GameStates; 120static GameStates gameState = WARMUP; 121 122/*-----( Class Objects )-----*/ 123FireTimer task_50ms; 124FireTimer task_250ms; 125DFPlayerMini_Fast dfPlayer; 126SR04 sonar = SR04(SONAR_ECHO_PIN, SONAR_TRIG_PIN); 127IRrecv irRecv(IR_DIGITAL_IN); 128decode_results irResults; 129LiquidCrystal_I2C lcdDisplay(0x27, 16, 2); // 16x2 LCD display 130 131/*-----( Functions )-----*/ 132void translateIR() // takes action based on IR code received 133{ 134 switch (irResults.value) 135 { 136 case 0xFFA25D: 137 Serial.println("POWER"); 138 if (gameState == WAIT) 139 { 140 gameInPlay = true; 141 } 142 break; 143 case 0xFFE21D: 144 Serial.println("FUNC/STOP"); 145 break; 146 case 0xFF629D: 147 Serial.println("VOL+"); 148 break; 149 case 0xFF22DD: 150 Serial.println("FAST BACK"); 151 break; 152 case 0xFF02FD: 153 Serial.println("PAUSE"); 154 remotePlay = !remotePlay; 155 break; 156 case 0xFFC23D: 157 Serial.println("FAST FORWARD"); 158 break; 159 case 0xFFE01F: 160 Serial.println("DOWN"); 161 break; 162 case 0xFFA857: 163 Serial.println("VOL-"); 164 break; 165 case 0xFF906F: 166 Serial.println("UP"); 167 break; 168 case 0xFF9867: 169 Serial.println("EQ"); 170 break; 171 case 0xFFB04F: 172 Serial.println("ST/REPT"); 173 break; 174 case 0xFF6897: 175 Serial.println("0"); 176 break; 177 case 0xFF30CF: 178 Serial.println("1"); 179 break; 180 case 0xFF18E7: 181 Serial.println("2"); 182 break; 183 case 0xFF7A85: 184 Serial.println("3"); 185 break; 186 case 0xFF10EF: 187 Serial.println("4"); 188 break; 189 case 0xFF38C7: 190 Serial.println("5"); 191 break; 192 case 0xFF5AA5: 193 Serial.println("6"); 194 break; 195 case 0xFF42BD: 196 Serial.println("7"); 197 break; 198 case 0xFF4AB5: 199 Serial.println("8"); 200 break; 201 case 0xFF52AD: 202 Serial.println("9"); 203 break; 204 case 0xFFFFFFFF: 205 Serial.println(" REPEAT"); 206 break; 207 208 default: 209 Serial.println(" other button "); 210 } 211} 212 213bool isPlayingSound() 214{ 215 return (digitalRead(DFPLAYER_BUSY_IN) == LOW); 216} 217 218void updateTimeDisplay(unsigned char digit, unsigned char num) 219{ 220 digitalWrite(SEGMENT_LATCH, LOW); 221 shiftOut(SEGMENT_DATA, SEGMENT_CLOCK, MSBFIRST, numbers[num]); 222 223 // Active LOW 224 digitalWrite(SEGMENT_1_OUT, digit == 1 ? LOW : HIGH); 225 digitalWrite(SEGMENT_2_OUT, digit == 2 ? LOW : HIGH); 226 digitalWrite(SEGMENT_3_OUT, digit == 3 ? LOW : HIGH); 227 228 digitalWrite(SEGMENT_LATCH, HIGH); 229} 230 231void updateServoPosition() 232{ 233 static int servoPulseCount = 0; 234 static bool lastPosition = false; 235 236 // Only get new value at start of period 237 if (servoPulseCount == 0) 238 lastPosition = faceTree; 239 240 if (!lastPosition) // 180 degrees 241 { 242 digitalWrite(SERVO_OUT, servoPulseCount < 5 ? HIGH : LOW); 243 } 244 else // 0 degrees 245 { 246 digitalWrite(SERVO_OUT, servoPulseCount < 1 ? HIGH : LOW); 247 } 248 249 servoPulseCount = (servoPulseCount + 1) % 40; // 20ms period 250} 251 252void updateMenuDisplay(const int button) 253{ 254 static int menuItem = 0; 255 static int menuOption = 0; 256 switch (button) 257 { 258 case 1: 259 menuItem = (menuItem + 1) % MENUITEM_COUNT; 260 if (menuItem == LANGUAGE) 261 { 262 menuOption = language; 263 } 264 else if (menuItem == PLAYTIME) 265 { 266 menuOption = playTime; 267 } 268 else if (menuItem == PLAYTYPE) 269 { 270 menuOption = playType; 271 } 272 else 273 { 274 menuOption = 0; 275 } 276 break; 277 case 2: 278 if (menuItem == LANGUAGE) 279 { 280 menuOption = (menuOption + 1) % LANUAGE_COUNT; 281 language = menuOption; 282 } 283 else if (menuItem == PLAYTIME) 284 { 285 menuOption = (menuOption + 1) % PLAYTIME_COUNT; 286 playTime = menuOption; 287 } 288 else if (menuItem == PLAYTYPE) 289 { 290 menuOption = (menuOption + 1) % PLAYTYPE_COUNT; 291 playType = menuOption; 292 } 293 else 294 { 295 menuOption = 0; 296 } 297 break; 298 case 3: 299 if (gameState == WAIT) 300 { 301 gameInPlay = true; 302 } 303 if (gameState == GREENLIGHT || gameState == REDLIGHT) 304 { 305 gameInPlay = false; 306 } 307 default: 308 break; 309 } 310 311 if (menuOption != -1) 312 { 313 lcdDisplay.clear(); 314 315 lcdDisplay.setCursor(0, 0); 316 lcdDisplay.print(MenuItems[menuItem]); 317 lcdDisplay.setCursor(0, 1); 318 319 if (menuItem == LANGUAGE) 320 { 321 lcdDisplay.print(Languages[menuOption]); 322 } 323 else if (menuItem == PLAYTIME) 324 { 325 lcdDisplay.print(PlayTime[menuOption]); 326 } 327 else if (menuItem == PLAYTYPE) 328 { 329 lcdDisplay.print(PlayType[menuOption]); 330 } 331 else 332 { 333 lcdDisplay.print("unknown option"); 334 } 335 } 336 else 337 { 338 menuItem = 0; 339 menuOption = 0; 340 } 341} 342 343void handleButtons() 344{ 345 static int buttonPressed = 0; 346 int value = analogRead(BUTTONS_IN); 347 348 if (value < 600) // buttons released 349 { 350 if (buttonPressed != 0) 351 updateMenuDisplay(buttonPressed); 352 353 buttonPressed = 0; 354 return; 355 } 356 else if (value < 700) 357 { 358 Serial.println("button 1"); 359 buttonPressed = 1; 360 } 361 else if (value < 900) 362 { 363 Serial.println("button 2"); 364 buttonPressed = 2; 365 } 366 else if (value < 1000) 367 { 368 Serial.println("button 3"); 369 buttonPressed = 3; 370 } 371 else 372 { 373 Serial.println(value); 374 buttonPressed = 0; 375 } 376} 377 378static int lastSonarValue = 0; 379void handleSonar() 380{ 381 int value = sonar.Distance(); 382 383 if (value > lastSonarValue + sonarVariance || 384 value < lastSonarValue - sonarVariance) 385 { 386 Serial.println(value); 387 lastSonarValue = value; 388 } 389} 390 391static int lastMotion = 0; 392void handleMotion() 393{ 394 int value = digitalRead(MOTION_IN); 395 396 if (value != lastMotion) 397 { 398 lastMotion = value; 399 } 400 401 if (lastMotion) 402 Serial.println("Motion Detected"); 403} 404 405void handleLeds() 406{ 407 digitalWrite(LED_RED, eyeColor == RED || eyeColor == WHITE || eyeColor == PURPLE || eyeColor == YELLOW ? HIGH : LOW); 408 digitalWrite(LED_GREEN, eyeColor == GREEN || eyeColor == WHITE || eyeColor == YELLOW ? HIGH : LOW); 409 digitalWrite(LED_BLUE, eyeColor == BLUE || eyeColor == WHITE || eyeColor == PURPLE ? HIGH : LOW); 410} 411 412void handleRemote() 413{ 414 // have we received an IR signal? 415 if (irRecv.decode(&irResults)) 416 { 417 translateIR(); 418 irRecv.resume(); // receive the next value 419 } 420} 421 422// Timer 1 ISR 423ISR(TIMER1_COMPA_vect) 424{ 425 // Allow this ISR to be interrupted 426 sei(); 427 428 updateServoPosition(); 429 430 if (timer_1000ms++ == TIMER_FREQUENCY) 431 { 432 timer_1000ms = 0; 433 countDown--; 434 if (countDown < 0) 435 { 436 countDown = 0; 437 } 438 } 439 440 if (timer_2ms++ == TIMER_2MS) 441 { 442 timer_2ms = 0; 443 if (digit == 0) 444 updateTimeDisplay(1, countDown % 10); 445 if (digit == 1) 446 updateTimeDisplay(2, (countDown / 10) % 10); 447 if (digit == 2) 448 updateTimeDisplay(3, (countDown / 100) % 10); 449 if (digit == 3) 450 updateTimeDisplay(4, 16); 451 452 digit = ((digit + 1) % 4); 453 } 454} 455 456void playGame() 457{ 458 static int sequence = 0; 459 static long internalTimer = millis(); 460 static bool closerClipPlayed = false; 461 static bool hurryUpClipPlayed = false; 462 static int captureDistance = 0; 463 long currentTimer = internalTimer; 464 465 if(isPlayingSound()) return; 466 467 if (gameState == WARMUP) 468 { 469 // power up sound 470 if (sequence == 0) 471 { 472 Serial.println("Warming Up"); 473 dfPlayer.playFolder(1, 1); 474 faceTree = false; 475 eyeColor = YELLOW; 476 sequence++; 477 } 478 479 // laugh at 30 480 else if (sequence == 1 && countDown <= 30) 481 { 482 Serial.println("Laughing"); 483 dfPlayer.playFolder(1, 2); 484 faceTree = true; 485 sequence++; 486 } 487 488 else if (sequence == 2 && countDown <= 10) 489 { 490 Serial.println("Almost ready"); 491 dfPlayer.playFolder(1, 3); 492 sequence++; 493 } 494 495 else if (sequence == 3 && countDown == 0) 496 { 497 Serial.println("All ready, lets play"); 498 dfPlayer.playFolder(1, 4); 499 faceTree = false; 500 sequence = 0; 501 gameState = WAIT; 502 gameInPlay = false; 503 } 504 } 505 506 else if (gameState == WAIT) 507 { 508 currentTimer = millis(); 509 510 if (gameInPlay) 511 { 512 gameState = READY; 513 remotePlay = false; 514 sequence = 0; 515 } 516 517 // Every 30 seconds 518 else if (currentTimer - internalTimer > 30000 || 519 sequence == 0) 520 { 521 internalTimer = millis(); 522 523 if(playType == AUTO) 524 { 525 // press the go button when you are ready 526 Serial.println("Press the go button when you are ready"); 527 dfPlayer.playFolder(1, 5); 528 } 529 else 530 { 531 Serial.println("Press the power button on the remote when you are ready"); 532 dfPlayer.playFolder(1, 6); 533 } 534 535 // eyes are blue 536 eyeColor = BLUE; 537 538 // facing players 539 faceTree = false; 540 541 gameInPlay = false; 542 543 sequence++; 544 } 545 } 546 547 else if (gameState == READY) 548 { 549 currentTimer = millis(); 550 551 if (sequence == 0) 552 { 553 // get in position, game will start in 10 seconds 554 Serial.println("Get in position."); 555 dfPlayer.playFolder(1, 7); 556 countDown = 10; 557 558 // eyes are green 559 eyeColor = WHITE; 560 561 // facing players 562 faceTree = false; 563 564 sequence++; 565 566 internalTimer = millis(); 567 } 568 else if (sequence == 1) 569 { 570 if (playType == REMOTE) 571 { 572 if (remotePlay) 573 sequence++; 574 } 575 else 576 sequence++; 577 } 578 else if (sequence == 2) 579 { 580 // at 0 seconds, here we go! 581 if (countDown == 0) 582 { 583 countDown = playTimes[playTime]; 584 Serial.print("play time set to "); 585 Serial.println(countDown); 586 587 Serial.println("Here we go!"); 588 dfPlayer.playFolder(1, 8); 589 gameState = GREENLIGHT; 590 sequence = 0; 591 } 592 } 593 } 594 595 else if (gameState == GREENLIGHT) 596 { 597 currentTimer = millis(); 598 599 if (sequence == 0) 600 { 601 // eyes are green 602 eyeColor = GREEN; 603 604 // play green light 605 Serial.println("Green Light!"); 606 dfPlayer.playFolder(1, 9); 607 608 sequence++; 609 } 610 611 else if(sequence == 1) 612 { 613 // play motor sound 614 dfPlayer.playFolder(1, 19); 615 616 // facing tree 617 faceTree = true; 618 619 sequence++; 620 621 internalTimer = millis(); 622 } 623 624 else if (sequence == 2) 625 { 626 // wait 3 seconds or until remote 627 // switch to red light 628 if (playType == AUTO && currentTimer - internalTimer > GREEN_LIGHT_MS) 629 { 630 sequence = 0; 631 gameState = REDLIGHT; 632 } 633 else if (playType == REMOTE && remotePlay == false) 634 { 635 sequence = 0; 636 gameState = REDLIGHT; 637 } 638 else 639 { 640 // look for winner button or distance 641 if (gameInPlay == false || 642 lastSonarValue < WIN_PROXIMITY_CM) 643 { 644 sequence = 0; 645 gameState = WIN; 646 } 647 648 else if (countDown <= 0) 649 { 650 Serial.println("Out of Time"); 651 dfPlayer.playFolder(1, 16); 652 sequence = 0; 653 gameState = LOSE; 654 } 655 656 // at 2 meters play "your getting closer" 657 else if (lastSonarValue < CLOSE_PROXIMITY_CM && 658 closerClipPlayed == false) 659 { 660 Serial.println("Getting closer!"); 661 dfPlayer.playFolder(1, 11); 662 closerClipPlayed = true; 663 } 664 665 // if less than 5 seconds play better hurry 666 else if (countDown <= BETTER_HURRY_S && 667 hurryUpClipPlayed == false) 668 { 669 Serial.println("Better Hurry"); 670 dfPlayer.playFolder(1, 12); 671 hurryUpClipPlayed = true; 672 } 673 } 674 } 675 } 676 677 else if (gameState == REDLIGHT) 678 { 679 currentTimer = millis(); 680 681 if (sequence == 0) 682 { 683 // eyes are red 684 eyeColor = RED; 685 686 Serial.println("Red Light!"); 687 688 if(language == ENGLISH) 689 { 690 // play red light English 691 dfPlayer.playFolder(1, 10); 692 } 693 else 694 { 695 // play red light Korean 696 dfPlayer.playFolder(1, 18); 697 } 698 699 sequence++; 700 } 701 702 else if(sequence == 1) 703 { 704 // play motor sound 705 dfPlayer.playFolder(1, 19); 706 707 // facing players 708 faceTree = false; 709 710 // Save current distance 711 captureDistance = lastSonarValue; 712 713 sequence++; 714 715 internalTimer = millis(); 716 } 717 718 else if (sequence == 2) 719 { 720 //wait for motion to settle 721 if (lastMotion == 0 || (currentTimer - internalTimer) > WAIT_FOR_STOP_MOTION_MS) 722 { 723 internalTimer = millis(); 724 sequence++; 725 Serial.println("Done settling"); 726 } 727 Serial.println("Waiting to settle"); 728 } 729 730 else if (sequence == 3) 731 { 732 // back to green after 5 seconds 733 if (playType == AUTO && currentTimer - internalTimer > RED_LIGHT_MS) 734 { 735 sequence = 0; 736 gameState = GREENLIGHT; 737 } 738 else if (playType == REMOTE && remotePlay == true) 739 { 740 sequence = 0; 741 gameState = GREENLIGHT; 742 } 743 744 else 745 { 746 // can't push the button while red light 747 // detect movement 748 // detect distance change 749 if (gameInPlay == false || 750 lastMotion == 1 || 751 lastSonarValue < captureDistance) 752 { 753 Serial.println("Movement detected!"); 754 dfPlayer.playFolder(1, 15); 755 sequence = 0; 756 gameState = LOSE; 757 } 758 759 if (countDown == 0) 760 { 761 Serial.println("Out of time"); 762 dfPlayer.playFolder(1, 16); 763 sequence = 0; 764 gameState = LOSE; 765 } 766 } 767 } 768 } 769 770 else if (gameState == WIN) 771 { 772 if (sequence == 0) 773 { 774 // play winner sound 775 Serial.println("You Won!"); 776 dfPlayer.playFolder(1, 13); 777 778 // eyes are white 779 eyeColor = WHITE; 780 781 // facing players 782 faceTree = false; 783 784 sequence++; 785 } 786 787 else if (sequence == 1) 788 { 789 // wanna play again? 790 Serial.println("Play Again?"); 791 dfPlayer.playFolder(1, 17); 792 793 gameInPlay = false; 794 countDown = 0; 795 796 // go to wait 797 gameState = WAIT; 798 sequence = 0; 799 } 800 } 801 802 else if (gameState == LOSE) 803 { 804 if (sequence == 0) 805 { 806 // sorry better luck next time 807 Serial.println("Sorry, you lost"); 808 dfPlayer.playFolder(1, 14); 809 810 // eyes are purple 811 eyeColor = PURPLE; 812 813 // face players 814 faceTree = false; 815 816 sequence++; 817 } 818 819 else if (sequence == 1) 820 { 821 // wanna play again? 822 Serial.println("Play Again?"); 823 dfPlayer.playFolder(1, 17); 824 825 gameInPlay = false; 826 countDown = 0; 827 828 // go to wait 829 gameState = WAIT; 830 sequence = 0; 831 } 832 } 833 else 834 { 835 //Shouldn't ever get here 836 gameState = WARMUP; 837 } 838} 839 840void loop() /*----( LOOP: RUNS CONSTANTLY )----*/ 841{ 842 if (task_50ms.fire()) 843 { 844 handleRemote(); 845 handleButtons(); 846 } 847 848 if (task_250ms.fire()) 849 { 850 handleSonar(); 851 handleMotion(); 852 handleLeds(); 853 playGame(); 854 855 Serial.println(isPlayingSound()); 856 } 857} 858 859// Setup Timer 1 for 2000Hz 860void setupTimer() 861{ 862 cli(); //stop interrupts 863 TCCR1A = 0; // set entire TCCR1A register to 0 864 TCCR1B = 0; // same for TCCR1B 865 TCNT1 = 0; //initialize counter value to 0 866 // set compare match register 867 OCR1A = TIMER_MATCH; // = (16*10^6) / (2000*64) - 1 (must be <65536), 2000Hz 868 // turn on CTC mode 869 TCCR1B |= (1 << WGM12); 870 // Set CS11 and CS10 bits for 64 prescaler 871 TCCR1B |= (1 << CS11) | (1 << CS10); 872 // enable timer compare interrupt 873 TIMSK1 |= (1 << OCIE1A); 874 sei(); //allow interrupts 875} 876 877void setup() 878{ 879 Serial.begin(9600); 880 881 pinMode(MOTION_IN, INPUT); 882 pinMode(BUTTONS_IN, INPUT); 883 pinMode(DFPLAYER_BUSY_IN, INPUT); 884 885 pinMode(SERVO_OUT, OUTPUT); 886 pinMode(LED_RED, OUTPUT); 887 pinMode(LED_GREEN, OUTPUT); 888 pinMode(LED_BLUE, OUTPUT); 889 890 pinMode(SEGMENT_LATCH, OUTPUT); 891 pinMode(SEGMENT_CLOCK, OUTPUT); 892 pinMode(SEGMENT_DATA, OUTPUT); 893 894 pinMode(SEGMENT_1_OUT, OUTPUT); 895 pinMode(SEGMENT_2_OUT, OUTPUT); 896 pinMode(SEGMENT_3_OUT, OUTPUT); 897 898 irRecv.enableIRIn(); // Start the receiver 899 dfPlayer.begin(Serial); // Use the standard serial stream for DfPlayer 900 dfPlayer.volume(VOLUME); // Set the DfPlay volume 901 lcdDisplay.init(); // initialize the lcd 902 lcdDisplay.backlight(); // Turn on backlight 903 setupTimer(); // Start the high resolution timer ISR 904 905 // Display welcome message 906 lcdDisplay.setCursor(0, 0); 907 lcdDisplay.print("Welcome to the"); 908 lcdDisplay.setCursor(0, 1); 909 lcdDisplay.print("Squid Games!"); 910 911 // short delay to display welcome screen 912 delay(1000); 913 914 task_50ms.begin(50); // Start the 50ms timer task 915 task_250ms.begin(250); // Start the 250ms timer task 916} 917
Downloadable files
Wire diagram
This is how I connected all of the components to the UNO.
Wire diagram
The project repo
All of the files for this build are stored here.
https://github.com/CodeMakesItGo/SquidGamesDoll
Wire diagram
This is how I connected all of the components to the UNO.
Wire diagram
The project repo
All of the files for this build are stored here.
https://github.com/CodeMakesItGo/SquidGamesDoll
Comments
Only logged in users can leave comments