Create a vintage aspetto jukebox to play an mp3 file with the DFRobot Mini Player plug.
Devices and components
Arduino-Nano
DC/DC step-down converter with 1.2-30V 5A output
Arduino Mega 2560 Rev3
Assorted DuPont threads
Adafruit Neopixel 60 LED Digital RGB LED Strip
4x4 button keyboard
Resistance 1k ohm
20 x 4 LCD screen with I2C module
Arduino compatible active buzzer module
DFRobot DF Player Mini
LED ring 24 LEDs
Various carpentry materials
230V AC/12V DC power supply
30W amplifier
GETTONIERA
Materials and tools
Hot glue gun (generic)
Tools for wood and metal working
Other common tool like saw, pliers, screwdriver and knives
Software and tools
Arduino IDE
Project description
Juke Box
1#include "DFRobotDFPlayerMini.h"
2#include <SoftwareSerial.h>
3SoftwareSerial mySerial(18, 19); // RX, TX
4DFRobotDFPlayerMini myMP3;
5
6#include <Adafruit_NeoPixel.h>
7#define LED_PIN 8
8// How many NeoPixels are attached to the Arduino?
9#define LED_COUNT 24
10Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
11
12
13#include <LiquidCrystal_I2C.h>
14LiquidCrystal_I2C lcd(0x27, 20, 4); // set the LCD address to 0x27 for a 16 chars and 2 line display
15
16#include <Keypad.h>
17const byte ROWS = 4; //four rows
18const byte COLS = 4; //three columns
19
20char keys[ROWS][COLS] = {
21 {'1','2','3','A'},
22 {'4','5','6','B'},
23 {'7','8','9','C'},
24 {'*','0','#','D'}
25};
26
27byte colPins[COLS] = {39,41,43,45}; //connect to the row pinouts of the keypad
28byte rowPins[ROWS] = {31,33,35,37}; //connect to the column pinouts of the keypad
29Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
30
31
32char key,keya;
33int sensore=2,contatore=0,buzzer = 12,selezione = 0, BusyPin = 13,song;
34
35
36String num1,num2,num3,lett;
37int alpha,moltiplica,cifra1,cifra2,cifra3,progress;
38
39void setup() {
40 pinMode (sensore, INPUT);
41 pinMode(BusyPin, INPUT_PULLUP);
42
43 lcd.init(); // initialize the lcd
44 lcd.backlight();
45
46 strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
47 strip.show(); // Turn OFF all pixels ASAP
48 strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
49
50
51 Serial.begin (9600);
52 Serial1.begin(9600);
53 myMP3.begin(Serial1, true);
54
55 delay(1000);
56
57 Serial.println("Setting volume to max");
58 myMP3.volume(30);
59
60 //----Set different EQ----
61 // myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
62 // myDFPlayer.EQ(DFPLAYER_EQ_POP);
63 //myMP3.EQ(DFPLAYER_EQ_ROCK);
64 // myDFPlayer.EQ(DFPLAYER_EQ_JAZZ);
65 // myDFPlayer.EQ(DFPLAYER_EQ_CLASSIC);
66 myMP3.EQ(DFPLAYER_EQ_BASS);
67
68 //----Mp3 control----
69 // myDFPlayer.sleep(); //sleep
70 // myDFPlayer.reset(); //Reset the module
71 myMP3.enableDAC(); //Enable On-chip DAC
72 // myDFPlayer.disableDAC(); //Disable On-chip DAC
73 // myDFPlayer.outputSetting(true, 15); //output setting, enable the output and set the gain to 15
74
75}
76void loop() {
77 gettone();
78 // TOGLI IL COMMENTO PER ABILITARE LA GETTONIERA
79
80 lcd.clear();
81 lcd.setCursor(3, 0);
82 lcd.print("J U K E B O X");
83 select();
84
85 myMP3.play(progress);
86 delay(1000);
87durata:
88 if (digitalRead(BusyPin) == LOW) {
89 theaterChase(strip.Color(127, 127, 127), 50); // White, half brightness
90 goto durata;
91 }
92 strip.clear();
93 strip.show();
94 }
95
96
97void select() {
98 lcd.setCursor(3, 1);
99 lcd.print("Selezione ");
100
101numero:
102 key = myKeypad.getKey();
103 if (key != NO_KEY && (key == '1' || key == '2' || key == '3' || key == '4' || key == '5' || key == '6' || key == '7' || key == '8' || key == '9' || key == '0'))
104 {
105 num1 = key;
106 //cifra1 = int((num1.toInt()) * 100);
107 cifra1 = int(num1.toInt());
108 Serial.println (num1);
109 lcd.setCursor(13, 1);
110 lcd.print(cifra1);
111 tone(buzzer, 770, 300);
112 }
113 else goto numero;
114 delay (200);
115
116numero2:
117 key = myKeypad.getKey();
118 if (key != NO_KEY && (key == '1' || key == '2' || key == '3' || key == '4' || key == '5' || key == '6' || key == '7' || key == '8' || key == '9' || key == '0'))
119 {
120 num2 = key;
121 tone(buzzer, 770, 300);
122 // cifra1 = int((num1.toInt()) * 10);
123 cifra2 = int(num2.toInt());
124 lcd.setCursor(14, 1);
125 lcd.print(cifra2);
126 Serial.println (cifra2);
127 }
128 else goto numero2;
129
130numero3:
131 key = myKeypad.getKey();
132 if (key != NO_KEY && (key == '1' || key == '2' || key == '3' || key == '4' || key == '5' || key == '6' || key == '7' || key == '8' || key == '9' || key == '0'))
133 {
134 num3 = key;
135 tone(buzzer, 770, 300);
136 cifra3 = int(num3.toInt());
137 progress = (cifra1*100) + (cifra2*10) + cifra3;
138
139 lcd.setCursor(15, 1);
140 lcd.print(cifra3);
141
142 Serial.println (progress);
143 }
144 else goto numero3;
145
146 lcd.setCursor(1, 3);
147 lcd.print ("Play Song num "); lcd.print(progress);
148
149
150 Serial.print ("selezione ===> "); Serial.print(lett); Serial.println (cifra3);
151 Serial.print ("Progressivo ===> "); Serial.println(progress);
152 delay (200);
153}
154
155void theaterChase(uint32_t color, int wait) {
156 for (int a = 0; a < 10; a++) { // Repeat 10 times...
157 for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2...
158 strip.clear(); // Set all pixels in RAM to 0 (off)
159 // 'c' counts up from 'b' to end of strip in steps of 3...
160 for (int c = b; c < strip.numPixels(); c += 3) {
161 strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
162 }
163 strip.show(); // Update strip with new contents
164 delay(wait); // Pause for a moment
165 }
166 }
167}
168void gettone(){
169
170lcd.clear();
171 lcd.setCursor(3, 0);
172 lcd.print("J U K E B O X");
173 lcd.setCursor(2, 1);
174 lcd.print(" Insert ");
175 lcd.setCursor(0, 2);
176 lcd.print("two x 20 cent coins ");
177 lcd.setCursor(2, 3);
178 lcd.print("for one play");
179
180coin1:
181 if (digitalRead(sensore) == LOW) {
182 contatore ++;
183 Serial.println ("inserita 1");
184 Serial.println (contatore);
185 lcd.setCursor(0, 2);
186 lcd.print(" another coin ");
187 tone(buzzer, 770, 300);
188 tone(buzzer, 970, 400);
189 delay (1000);
190 }
191 else goto coin1;
192 coin2:
193 if(digitalRead(sensore) == LOW) {
194 contatore ++;
195 Serial.println ("inserita 2");
196 Serial.println (contatore);
197 }
198 else goto coin2;
199 tone(buzzer, 770, 300);
200 delay (1000);
201}
Downloadable files
progetto
project.jpg
Note: Content and images are from: https://projecthub.arduino.cc/, with some modifications.
If you want it removed due to copyright reasons, please leave a comment. Thank you.
I want to share this article more widely so that everyone knows about Arduino and your project.