Skip to content

Commit a51190a

Browse files
author
LuiCat
authored
Create README.md
1 parent 9572bf4 commit a51190a

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# ArduinoTaikoController
2+
3+
Sketch for Arduino based taiko game controller circuit
4+
5+
## Circuit Setup
6+
7+
For most of the times, pluging the sensors directly into Arduino's analog pins will work.
8+
But for most of the times you'd better connect a resistor in parallel or an RC low-pass circuit for each sensor.
9+
10+
For different types of sensors, you have to determine the amplitute of output level on arduino.
11+
By using a maximum reference voltage and enabling debug info you can see the input voltage level in 1/1024 of the reference voltage.
12+
Then you should choose a reference voltage wisely, using either pre-built 5V/1.1V or external voltage sources.
13+
14+
## Algorithm
15+
16+
This controller program uses a dynamic threshold of sensor input levels to trigger an input.
17+
Everytime a sensor gives a significantly higher input level, the algorithm sets the threshold of this sensor to that input level, and gradually lowers the threshold.
18+
To avoid picking up inputs from other sensors erroneously, when a sensor is recognized as triggered, the threshold level of all other sensors is raised as well.
19+
Also, a cooldown length will be added to all sensors so to ignore the unstable levels near a drum hit.
20+
21+
## Parameters (with suggested values)
22+
23+
#### min_threshold = 20
24+
The minimum level that a trigger is recognized for all sensors.
25+
26+
To determine an optimal value for this level, try enabling debug info.
27+
Usually, this value is only used to ignore sensor noises, but you can use this level as a sensitivity level.
28+
29+
#### cd_length = 8000
30+
The cooldown length of the triggered sensor, in microseconds (1x10^-6).
31+
32+
While a sensor is in its cooldown period, no input will be generated for it, but the threshold level would still be updated.
33+
During the cooldown period, the corresponding key of the sensor is kept pressed. When it ended, the key is released.
34+
35+
#### cd_antireso_length = 8000
36+
The cooldown length of sensors other than the triggered one, in microseconds.
37+
38+
When there's a drum hit on one part of the drum, other parts will still have fluctuations in sensor levels.
39+
By using cooldown periods for sensors other than the triggered one, we are able to let these sensors settle down and also get their threshold level updated,
40+
so that there will not be any mistrigger after the cooldown period expires.
41+
42+
#### k_antireso = 0.85
43+
How much the thresholds of every sensor other than the triggered one are raised to, in ratio to the threshold of the triggered sensor.
44+
45+
#### k_decay = 0.96
46+
How fast every threshold level decays, in ratio.
47+
48+
For approximately every millisecond the threshold is lowered by k_decay.
49+
50+
#### pin[4] = {A3, A0, A2, A1}
51+
The analog input pins of four sensors.
52+
53+
#### key[4] = {'d', 'f', 'j', 'k'}
54+
The key mapping of four sensors.
55+
56+
## Debug Info
57+
58+
If the macro ```DEBUG_OUTPUT``` is enabled, there will be debug info printed via serial. Take a look at your serial monitor.
59+
60+
The first 4 rows indicates current vibration level of the four sensors, and the last 4 rows indicates the minimum level for a sensor to trigger a input;
61+
the symbols in the middle shows current status of the sensors, # for input triggered and * for anti-resonance state.
62+
63+
A typical output could be:
64+
65+
```
66+
0 3 13 63 | | 0 0 0 0
67+
51 2 11 58 | * * * # | 53 53 53 63
68+
83 5 9 24 | # * * # | 83 70 70 70
69+
```
70+

0 commit comments

Comments
 (0)