-
Notifications
You must be signed in to change notification settings - Fork 1
/
CopyPasteVolume.ino
56 lines (49 loc) · 1.15 KB
/
CopyPasteVolume.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
56
// Tools -> Board:
// SparkFun Pro Micro
// Pro Micro ATmega32U4 5V 16MHz
// Two buttons and one potentiometer
#include "HID-Project.h"
int ButtonGreen = 3;
int ButtonRed = 5;
int PotPin = A3;
int PotValue = 0;
int currVolume = 0;
void setup()
{
pinMode(ButtonGreen, INPUT_PULLUP); // Common Ground. reverse logic.
pinMode(ButtonRed, INPUT_PULLUP);
digitalWrite(ButtonGreen, HIGH);
digitalWrite(ButtonRed, HIGH);
Keyboard.begin();
delay(500); // short delay to let outputs settle
Consumer.begin();
delay(500);
}
void loop()
{
if (digitalRead(ButtonGreen) == LOW)
{
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press('c');
delay(100);
Keyboard.releaseAll();
delay(200);
}
if (digitalRead(ButtonRed) == LOW)
{
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press('v');
delay(100);
Keyboard.releaseAll();
delay(200);
}
PotValue = map(analogRead(PotPin), 0, 1023, 0, 50);
if (currVolume < PotValue) {
Consumer.write(MEDIA_VOLUME_UP);
currVolume++;
}
if (currVolume > PotValue) {
Consumer.write(MEDIA_VOLUME_DOWN);
currVolume--;
}
}