This the light choking things code and wiring.
int aIn = 0; //Sensor input pin (the white wire)
int aOut = 9; //LED and speaker output pins
int bOut = 10;
int cOut = 11;
int aVal = 0; //Variable for the sensor
int i = 0; //Loop counter
int wait = (1000); //Delay between input and output
int checkSum =0; //I have no idea what this does
int prevCheckSum = 0;
int sens = 3; //Threshold for the senstivity to
//prevent too small changes from the
//sensor to make effect
int PRINT = 1; //No idea what this does (1=one)
void setup()
{
pinMode(aOut+bOut+cOut, OUTPUT); //Sets the output to digital pins
Serial.begin(9600); //Gives an order to talk back to the computer
//at 9600 baud
}
void loop()
{
i += 1; //Loop count (1=one)
aVal = analogRead(aIn) / 4; //reads the analog input, and converts to 0-255 scale (divides it by 4)
analogWrite(aOut, aVal); //these send the values read from the
analogWrite(bOut, aVal); //sensor to the outputs (aVal is the sensor,
analogWrite(cOut, aVal); //aOut+bOut+cOut are outputs
if (i % wait == 0) //this adds the values by 3, I’m not sure if this needed
{
checkSum = aVal;
if ( abs(checkSum – prevCheckSum) > sens )
{
if (PRINT)
{
Serial.print(“A: “); //this prints the values on screen, not sure if this is needed either
Serial.print(aVal);
Serial.print(“\t”);
PRINT = 0;
}
}
else
{
PRINT = 1;
}
prevCheckSum = checkSum; //Updates the values
}
}