So im working on a project that uses photo diodes to detect edges.
The arduino (mega) uses 5 digital outputs (20,22,24,26,28) to control my multiplexer. Right now i am just trying to get two photodiodes to be used.
Essentially the arduino is supposed to read the analog input of the photodiode, set it to a variable, switch the multiplexer so the circuit is connected to the other photodiode, again read the value and set it to a variable, then compare the two values.
IF the difference between the two photodiodes is greater than 100 (which is a value that will be changed to tune the device). The arduino will then set pin 53, which is connected to an LED high. If the diffrerence is less than 100, the LED remains off.
int var1;
int var2;
void setup()
{
pinMode( 24 , OUTPUT);
pinMode( 20 , OUTPUT);
var1 = 0;
pinMode( 22 , OUTPUT);
pinMode( 28 , OUTPUT);
pinMode( 26 , OUTPUT);
var2 = 0;
pinMode( 53 , OUTPUT);
}
void loop()
{
digitalWrite( 22 , LOW );
digitalWrite( 24 , LOW );
digitalWrite( 26 , LOW );
digitalWrite( 28 , LOW );
digitalWrite( 20 , LOW );
var1 = analogRead(12) ;
digitalWrite( 28 , HIGH );
var2 = analogRead(12) ;
if (( ( 100 ) < ( abs( ( var1 - var2 ) ) ) ))
{
digitalWrite( 53 , HIGH );
}
else
{
digitalWrite( 53 , LOW );
}
}
Thanks for your help