Linearity Test Circuit

Here’s more information on the circuit I used to do the linearity tests:

Arduino blinker circuit

 

The circuit as set up

 

Pin 3 (connected with the green wire above) is set as a ‘pull-up’ input so that with the wire inserted and connected to ground it is Low, but when the wire is pulled out, the Arduino pulls it High.  The LED lights for the specified number of pulses when the wire is pulled out.  Reinserting this wire resets the circuit ready for the next set of pulses.

The LED is 3mm orange:

 

  • Brightness: 40mcd
  • Voltage Typical: 2V
  • Voltage Max: 2.6V
  • Current: 30mA

 

At 2V across the LED and 30mA, I needed a 100 ohm resistor.  Using what I had to hand I actually used 3 x 330 ohm resistors in parallel (equiv to 110 ohm).

 

The Arduino code is below:


/*
Blink_ext_LED

Turns an LED on for a specified number of time, with a gap in between to allow LED to cool.
Used to test camera sensor for linearity

by TG Tan
1/2/21
*/

// this is the number of times the LED will blink – use to set the exposure
int exposure = 132;

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 12 as an output.
pinMode(12, OUTPUT);
// pin 3 High (ie ground wire pulled out) will start an exposure
pinMode(3, INPUT_PULLUP);
}

// the loop function runs over and over again forever
void loop() {
while (true){
if (digitalRead(3)) break;
}
// start exposure if the ground wire is pulled out, otherwise stay in infinite loop

for (int i=0; i<exposure; i=i+1){
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1); // hold the LED on
digitalWrite(12, LOW); // turn the LED off by making the voltage LOW
delay(10); // wait to allow cooldown
}
// waits indefinitely until the ground wire is reinserted
while (true){
if (!digitalRead(3)) {
// sometimes reinserting the wire causes low then high again
// wait to make sure the wire is in properly
delay(5);
if (!digitalRead(3)) break;
}
}
}

Home