You are on page 1of 2

const int ProxSensor=2;

int inputVal =0;

void setup()

pinMode(12, OUTPUT);

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

// Pin 13 has an LED connected on most Arduino boards:

pinMode(ProxSensor,INPUT); //Pin 2 is connected to the output of proximity sensor

Serial.begin(9600);

void loop()

if(digitalRead(ProxSensor)==HIGH) //Check the sensor output

digitalWrite(12, HIGH); // set the LED on

else

digitalWrite(12, LOW); // set the LED of

inputVal = analogRead(ProxSensor);

Serial.println(inputVal);
delay(1000); // wait for a second

if(inputVal<=10){

digitalWrite(12, HIGH);

digitalWrite(8, HIGH);

digitalWrite(9, HIGH);

You might also like