semestralka
[mirrors/Programs.git] / arduino / oscilator / oscilator.pde
CommitLineData
a3a3e374
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 = 70;
8char offset = 0;
9float val = 0, oldval = -255;
10int sndPin = 12;
11
12void setup() // run once, when the sketch starts
13{
14 stadium_max+=offset;
15 Serial.begin(19200);
16 pinMode(sndPin, OUTPUT);
17}
18
19void loop() // run over and over again
20{
21 val = analogRead(inpin);
22 if(val<min) min=val;
23 if(val>max) max=val;
24 val=(((val-(min))/(max-(min)))*stadium_max)-offset;
25 /*if(val!=oldval) {
26 oldval = val;
27 //Serial.print(min, DEC); Serial.print("-"); Serial.print(max, DEC); Serial.print("\n");
28 //Serial.print(val, DEC); Serial.print("\n");
29 //Serial.print(val, BYTE);
30 }*/
31 val=val;
32 digitalWrite(sndPin, HIGH);
33 delay(val);
34 digitalWrite(sndPin, LOW);
35 delay(val);
36}
This page took 0.379275 seconds and 4 git commands to generate.