Wednesday 29 October 2014


  Small Solar Panel (5v)

Arduino Light Sensor

I think this retro-design could be used for a cool visual of a solar array functioning.



 How it works.

The solar panel puts out 5 volts when working well with lots of light. Be aware if the voltage goes above 5v you may damage your Arduino. In that case use a voltage divider. The voltage output (0 to 5v) is measured by the analogue pin on the Arduino. Some code below converts this to a series of pulses on digital pins to light an LED bar.

As light intensity grows (that's me moving the lamp over the panel), the LEDs pulse faster and show that the voltage output from the panel is increasing. If the panel fails, or the light goes out a buzzer sounds or pin 13. You could also use that concept to trigger events if panels are undercharging or overcharging.

I think this retro-design could be used for a cool visual of a solar array functioning. Its reminds me of those old films where the reactor is about to go critical or when they are have to push the power output of warp engines to the limit. In fact, I may add some sound effects code too ! :)

 Code:--------------------------------------------------------
// Initialise Global variables
int startPin = 2; // starting pin don't use 0 or 1 because they are Rx and Tx.
int LEDnum = 12; // highest pin No. 12 -2 = 10 LEDs
int lightPin = A5; //A5 for sensor: 5v max output from the solar panel

// use a 10K resistor as well, in series, to limit the current
int lightLevel = 0;
int myDelay = 0;
int buzzPin = 13; // alarm pin for buzzer

void setup()
{
  pinMode(buzzPin, OUTPUT);

  for (int PINi = startPin; PINi < LEDnum; PINi++)
  {
    pinMode(PINi, OUTPUT);

  }
  Serial.begin(9600);
}

void loop()
{
  lightLevel = analogRead(lightPin); //Read the level


  myDelay = 100 - (lightLevel / 10) ; // set delay according to light level

  Serial.println(myDelay); // debug in terminal window

// if lightlevel is very low ie delay is big, switch off all led and Alarm
  if (myDelay >= 85)
  {
    for (int PINi = startPin; PINi < LEDnum; PINi++)
    {
      digitalWrite(PINi, LOW); 
    }

    digitalWrite(buzzPin, HIGH);
    delay (500);
    digitalWrite(buzzPin, LOW);
    delay (500);
  }
 
// Display charging on LED bar
  else{
    for (int PINi = startPin; PINi < LEDnum; PINi++)
    {
      digitalWrite(PINi, HIGH);
     
      delay(myDelay);
      digitalWrite(PINi, LOW);.
     
    
    }
  }
}

end code:--------------------------------------------------------------

Wednesday 1 October 2014

Nikon Hacks Part VI

Nikon Flash and Arduino

Runner Beans - Ring Flash
Check my other site !

Introduction 

In this section I aim to trigger the shutter of the camera and the Flash using the Arduino. I need to experiment with bits of code to get triggering and delay times just right.
So far I have established that the minimum trigger time for my flash is 12us (twelve microseconds). That is the minimum time the Trigger pin can be grounded to fire the flash.
Here is the simple code for that: --------------------------------------------------------------
 /*
  FLASH


  This example code is in the public domain.
 */


int flash = 11; // trigger pin

// the flash triggers once when you press reset after a short delay:

void setup() {               
  // initialize the digital pin as an output.
  pinMode(flash, OUTPUT);  
 
digitalWrite(flash, HIGH);

delay(3000);

// fire flash once------------------------------------------

digitalWrite(flash, LOW);   // 
  delayMicroseconds(12);               // wait 12us minimum trigger time
  digitalWrite(flash, HIGH);  
               // wait  
}

// the loop routine runs over and over again forever:
void loop() {
 
}

End Flash code:------------------------------------------------------

I want to use the camera in Bulb mode:

1.ensure IR is off and  prepare camera for bulb mode to receive IR
2. trigger IR and open shutter
3. wait for exposure eg 10 secs
4. trigger IR and close shutter
5. check result 

I decided to use the Transistor method for triggering the IR remote:

Code for IR:------------------------------------------------------------
/*
  shutter IR


  This example code is in the public domain.
 */

int shutter = 10; //IR shutter pin

int flash = 12; // Flash trigger pin


void setup() {               
  // initialize the digital pin as an output.
  pinMode(flash, OUTPUT);  
  pinMode(shutter, OUTPUT);
 
  Serial.begin(9600);
  digitalWrite(shutter, HIGH); // high is IR OFF

Serial.println ("Prepare Camera - 30 sec");

delay(30000); //pause 30sec

}

//
void loop() {
 
//bulb mode

digitalWrite(shutter, LOW); // low is IR on open shutter
Serial.println ("IR ON 1 - open shutter");
delayTenthsSeconds (2); // 0.2 seconds trigger shutter
 
  digitalWrite(shutter, HIGH); // high is IR OFF
  Serial.println ("IR OFF");
delayTenthsSeconds (100);// ten seconds

digitalWrite(shutter, LOW); // low is IR on close shutter
Serial.println ("IR ON 2 - open shutter");
delayTenthsSeconds (2);

 
  digitalWrite(shutter, HIGH); // high is IR OFF
   Serial.println ("IR OFF");
//delayTenthsSeconds (10);
Serial.println ("CHECK RESULT");
delay(50000); // hold for check

}

void delayTenthsSeconds (int multi){// delay multi x 0.1 sec

    for (int i = 1; i < (multi * 100); i++) //
    {
      delayMicroseconds(1000);   // multi x 100     }
}

End Code for IR:--------------------------------------------------