Hi,
I'm very new to this but I'm trying to write a program using a Sharp GP2Y0A21YK infrared sensor and 1 LED for my class.
I want the LED to be on initially then once the sensor senses a value, I want the LED to blink 5 times then stop blinking.
So far I have this:
int sensorPin = 0;
int sensorVal = 0;
int ledPin = 13;
void setup(){
Serial.begin (9600);
pinMode (ledPin, OUTPUT);
}
void loop(){
Serial.println(sensorVal, DEC);
sensorVal = analogRead(sensorPin);
if(sensorVal = 250)
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, HIGH);
delay(1000);
}
else
{
digitalWrite(ledPin, LOW);
}
}
Does anyone know how to can achieve this? Thank you!