Movie controller on iPad with Arduino Jan 8th, 2012 Measuring the rotation speed of a computer fan with arduino, and using that as controller for the playback speed of movies on an iPad. // constants won't change. They're used here to // set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin // variables will change: int ledPin = 13; int val; long last=0; int stat=0; int stat2; int counter=0; int timer=1000; // the time it takes each reading void setup() { // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); Serial.begin(9600); Serial.println("Hello world"); delay(2000);// Give reader a chance to see the output. } void loop(){ // read the state of the pushbutton value: stat = digitalRead(buttonPin); digitalWrite(ledPin, stat); if(stat2 != stat) { // counts when the state change, thats from (dark to light) or // from (light to dark), remmember that IR light is invisible for us. counter++; stat2=stat; } if(millis()-last>=timer){ double rpm=(((double)counter)/(60000.0/timer)); Serial.print(rpm, DEC); Serial.print("\n"); counter=0; last=millis(); } }