pthread_pause pthread_unpause
[mirrors/Programs.git] / c / pong / pong.pde
CommitLineData
84aff5c8
H
1/* Pong controller (for use with hPong)
2 * <~~Harvie 2oo8
3 */
4
5#define inpin 0
6int min = 65535, max = 0;
7int stadium_max = 14;
8char offset = 8;
9float val = 0, oldval = -255;
10
11void setup() // run once, when the sketch starts
12{
13 stadium_max+=offset;
14 Serial.begin(115200);
15}
16
17void loop() // run over and over again
18{
19 val = analogRead(inpin);
20 if(val<min) min=val;
21 if(val>max) max=val;
22 val=(((val-(min))/(max-(min)))*stadium_max)-offset;
23 if(val!=oldval) {
24 oldval = val;
25 //Serial.print(min, DEC); Serial.print("-"); Serial.print(max, DEC); Serial.print("\n");
26 //Serial.print(val, DEC); Serial.print("\n");
27 Serial.print(val, BYTE);
28 }
29 delay(1);
30}
This page took 0.625129 seconds and 4 git commands to generate.