advice: spend time to proper spacing, empty lines and indentation, makes code more readable
See the code below (not fixed all of the above)
// Reports the frequency from the TSL230, higher number means brighter
// Part: http://www.sparkfun.com/products/8940
// Article: http://bildr.org/2011/08/tsl230r-arduino/
#include <Servo.h>
Servo myservo1;
int TSL230_Pin = 4; //TSL230 output
int TSL230_s0 = 3; //TSL230 sensitivity setting 1
int TSL230_s1 = 2; //TSL230 sensitivity setting 2
int TSL230_samples = 30; //higher = slower but more stable and accurate
boolean once = false;
void setup()
{
Serial.begin(9600);
setupTSL230();
pinMode(5,OUTPUT);
myservo1.attach(5);
}
void loop()
{
float lightLevel = readTSL230(TSL230_samples);
Serial.println(lightLevel);
if (lightLevel > 1800 && lightLevel < 10000 && once == true)
{
myservo1.writeMicroseconds(1300);delay(5000);
myservo1.writeMicroseconds(1500);delay(5000);
once = false;
}
if (lightLevel < 1800 && once == false)
{
myservo1.writeMicroseconds(1700);delay(5000);
myservo1.writeMicroseconds(1500);delay(5000);
once = true;
}
}
note readTSL230(TSL230_samples); is nowhere defined.