-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patharcade-led.ino
93 lines (81 loc) · 1.59 KB
/
arcade-led.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
Arcade LED button effects
Rodrigo Feliciano
https://www.pakequis.com.br
youtube.com/pakequis
*/
#include <SoftPWM.h> //library: https://github.com/bhagman/SoftPWM
//LED OFF to ON time (ms)
#define FADE_IN 50
//LED ON to OFF time (ms)
#define FADE_OUT 1000
//Number of Buttons and LED Channels
#define N_CHANNELS 8
/******************************/
/* Arduino Uno R3 */
//Buttons pins:
//#define BT1 A0
//#define BT2 A1
//#define BT3 A2
//#define BT4 A3
//#define BT5 A4
//#define BT6 A5
//#define BT7 1
//#define BT8 2
//LED pins
//#define LED1 3
//#define LED2 4
//#define LED3 5
//#define LED4 6
//#define LED5 7
//#define LED6 8
//#define LED7 9
//#define LED8 10
/******************************/
/******************************/
/* Arduino Mini Pro */
//Buttons pins:
#define BT1 A3
#define BT2 A2
#define BT3 A1
#define BT4 A0
#define BT5 13
#define BT6 12
#define BT7 11
#define BT8 10
//LED pins
#define LED1 2
#define LED2 3
#define LED3 4
#define LED4 5
#define LED5 6
#define LED6 7
#define LED7 8
#define LED8 9
/******************************/
int b[N_CHANNELS] = {BT1,BT2,BT3,BT4,BT5,BT6,BT7,BT8};
int LED[N_CHANNELS] = {LED1,LED2,LED3,LED4,LED5,LED6,LED7,LED8};
int i = 0;
void setup()
{
SoftPWMBegin();
for (i = 0; i < N_CHANNELS; i++)
{
SoftPWMSet(LED[i],0);
SoftPWMSetFadeTime(LED[i], FADE_IN, FADE_OUT);
pinMode(b[i],INPUT);
}
}
void loop()
{
for(i = 0; i < N_CHANNELS; i++)
{
if(!digitalRead(b[i]))
{
SoftPWMSet(LED[i], 0);
}else
{
SoftPWMSet(LED[i], 255);
}
}
}