Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. #include "Arduino.h"
  2. #include "SoftwareSerial.h"
  3. #include "DFRobotDFPlayerMini.h"
  4.  
  5. SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
  6. DFRobotDFPlayerMini myDFPlayer;
  7. void printDetail(uint8_t type, int value);
  8. const int VERDE = 5;
  9. const int BLU = 6;
  10. const int ROSSO = 3;
  11. const int LUCE1 = 8;
  12. const int LUCE2 = 9;
  13. const int TELECOM = 12;
  14.  
  15. // tempo di transizione colore
  16.  
  17.  
  18. void setup() {
  19. mySoftwareSerial.begin(9600);
  20. Serial.begin(115200);
  21.  
  22. Serial.println();
  23. Serial.println(F("DFRobot DFPlayer Mini Demo"));
  24. Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
  25.  
  26. if (!myDFPlayer.begin(mySoftwareSerial)) { //Use softwareSerial to communicate with mp3.
  27. Serial.println(F("Unable to begin:"));
  28. Serial.println(F("1.Please recheck the connection!"));
  29. Serial.println(F("2.Please insert the SD card!"));
  30. while(true);
  31. }
  32. Serial.println(F("DFPlayer Mini online."));
  33.  
  34. myDFPlayer.volume(30);
  35. //myDFPlayer.playFolder(15, 2);
  36.  
  37. //myDFPlayer.playMp3Folder(2);
  38. // imposta il pin digitale come output
  39. pinMode(VERDE, OUTPUT);
  40. pinMode(BLU, OUTPUT);
  41. pinMode(ROSSO, OUTPUT);
  42. pinMode(LUCE1, OUTPUT);
  43. pinMode(LUCE2, OUTPUT);
  44. pinMode(TELECOM, INPUT);
  45.  
  46. }
  47. void loop() {
  48.  
  49. int stato= digitalRead(TELECOM);
  50. //int stato;
  51. Serial.println(stato);
  52. if(stato==LOW) {
  53. digitalWrite(LUCE1, HIGH);
  54. digitalWrite(LUCE2, HIGH);
  55.  
  56. }
  57.  
  58. if(stato==HIGH){
  59. //digitalWrite(LUCE1, HIGH);
  60. //digitalWrite(LUCE2, HIGH);
  61. myDFPlayer.playMp3Folder(1);//rombo
  62.  
  63.  
  64. analogWrite( VERDE,0 );
  65. analogWrite( BLU, 0 );
  66. analogWrite( ROSSO, 255 );
  67.  
  68.  
  69. delay(9000);
  70. analogWrite( VERDE, 255 );
  71. analogWrite( BLU, 0 );
  72. analogWrite( ROSSO, 0 );
  73. myDFPlayer.playMp3Folder(2); //tanti auguri
  74.  
  75.  
  76.  
  77. delay(14000);// DURATA TANTI AUGURI
  78. myDFPlayer.playMp3Folder(3);// AVVIO CANZONE PETER PAN
  79. analogWrite( VERDE, 255 );
  80. analogWrite( BLU, 0 );
  81. analogWrite( ROSSO, 0 );
  82.  
  83. delay(153000);// DURATA peter pan
  84.  
  85.  
  86.  
  87. }
  88.  
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement