Jason's life is now perfect =)
Sunday, December 22, 2013
Arduino camera flash countdown code
// code loosly based on http://arduino.cc/en/Tutorial/BlinkWithoutDelay // wiring of the remote came from http://www.instructables.com/id/Homebew-Wired-SONY-ALPHA-Remote/ // which pins do what int led1 = 5; int led2 = 2; int led3 = 3; int led4 = 4; int flashpin = 12; int focuspin = 11; // all the random variables int flashed = 1; //has it flashed yet? long flashtime = 0; //what time should it flash? long led1time = 0; //when will led1 go off? long led2time = 0; //when will led2 go off? long led3time = 0; //when will led3 go off? long led4time = 0; //when will led4 go off? long time; //used to grab the millis void setup() { Serial.begin(9600); //used for troubleshooting // initialize the digital pins as outputs. pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(flashpin, OUTPUT); pinMode(focuspin, OUTPUT); pinMode(13, OUTPUT); //used for troubleshooting - would make pin 13 light instead of firing the camera } void loop() { if(flashed == 1) { time = millis(); //take a time reading flashtime = time + 8000; //now + 8 seconds it will flash led1time = time + 8000; //now + 8 seconds the last led will go out led2time = time + 7000; //now + 7 seconds the 2nd led will go out led3time = time + 6000; //now + 6 seconds the 3rd led will go out led4time = time + 5000; //now + 5 seconds the first led will go off, to signify the countdown digitalWrite(led4, HIGH); //turn all leds on digitalWrite(led3, HIGH); digitalWrite(led2, HIGH); digitalWrite(led1, HIGH); digitalWrite(flashpin, HIGH); //redundant, technically not needed... (maybe for first go round, before first flash?) digitalWrite(focuspin, HIGH); //redundant, technically not needed... flashed = 0; //start the "you haven't flashed so start the countdown" 'if' :) } //flashed end else { time = millis(); if(time > led4time) digitalWrite(led4, LOW); //start the countdown! if(time > led3time) digitalWrite(led3, LOW); // 3... if(time > led2time) digitalWrite(led2, LOW); // 2... if(time > led1time) digitalWrite(led1, LOW); // 1... if(time > flashtime) { digitalWrite(focuspin, LOW); //focusing (even if on manual focus - plus, if the focus pin is perma-focused, you can't review the pics, nor change any shutter type settings)... delay(400); digitalWrite(flashpin, LOW); // FLASH! digitalWrite(13, HIGH); //led on-board lights, showing visibal progess incase the camera didn't delay(400); //this was a good delay for my camera. 200 was too fast, any longer might fire more photos) digitalWrite(flashpin, HIGH); //stop flashing digitalWrite(focuspin, HIGH); //stop focusing digitalWrite(13, LOW); //turn off led flashed = 1; //you have flashed, start the countdown over again! } //flash end } //else end //Serial.print("time:"); Serial.print(time); Serial.print(" led1time:"); Serial.print(led1time); Serial.print(" flashtime:"); Serial.println(flashtime); // the above was useful when it wasn't flashing, nor were my leds going off. it showed the current time, when one of the leds was supposed to go off, and when it was supposed to flash. } //loop end
Friday, December 20, 2013
Jr raving
Friday, December 13, 2013
I guess it got a little cold in the truck last night
Friday, December 06, 2013
it's hot enough to be riding around with the windows down :-)
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)