-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton_random_song.ino
55 lines (43 loc) · 1.24 KB
/
button_random_song.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
Keyboard Message to play a random song in a Raspberry (or any computer)
For the Arduino Leonardo and Micro.
Requirements:
- Arduino Leonardo or Micro, Raspberry pi (or any computer). Speakers or earphones.
- Install vlc (``sudo apt install vlc``).
- Clone this repo in your ``/home/pi`` directory (modify if needed).
Sends a message to vlc to play a random song when a button is pressed.
The circuit:
- Button attached from pin 4 to +5V
- 10 kilohm resistor attached from pin 4 to ground
- Connect to a Raspberry Pi
- Connect the speakers
- Push the button for a random song
- Push again for a new random song
- Push reset button to stop
created 21 Sept 2020
by programandoconro
*/
#include "Keyboard.h"
boolean off = false;
const int buttonPin = 4;
void setup() {
pinMode(buttonPin, INPUT);
Keyboard.begin();
}
void loop() {
if (off == false) {
delay(1000);
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.write('c');
Keyboard.releaseAll();
off = true;
}
if (buttonState == true) {
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.write('c');
Keyboard.releaseAll();
delay(500);
Keyboard.println("cd /home/pi/Playlist-para-programar/Soundtrack && vlc . -Z");
delay(1000);
}
}