hi guys.
ive been having some problem figuring out the code for a fritsldr in arduino.
so far i keep getting this error:
error: expected unqualified-id before numeric constant.:
error: expected unqualified-id before numeric constant in function 'void loop()'
bad error line: -2
heres the code ive been using
int ledPin = 12
int ldrPin = 1
int speaker = 9
int ledon
int ledoff
int distance
void setup()
{
pinMode(ledPin, OUTPUT)
pinMode(speaker = OUTPUT)
}
void loop()
{
digitalWrite(ledPin,HIGH)
ledon = analogRead(ldrPin)
digitalWrite(ledPin,LOW)
ledoff = analogRead(ldrPin)
distance =(ledon - ledoff)
analogWrite(speaker, distance)
}
edit
problem solved on the code front.
just ont getting any response from anything as regards the distance.
new code
int ledPin = 12;
int ldrPin = 1;
int speaker = 9;
int ledon;
int ledoff;
int distance;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(speaker, OUTPUT);
}
void loop()
{
digitalWrite(ledPin,HIGH);
ledon = analogRead(ldrPin);
delay(100);
digitalWrite(ledPin,LOW);
ledoff = analogRead(ldrPin);
delay(100);
distance = (ledon - ledoff);
analogWrite(speaker, distance);
}
any help will be greatly received and appreciated
many thanks
Tom J