IMAG2247 IMAG2248

Hardware connection

Sensor  ………  Arduino

+………………..5V

G……………….GND

A0………………A0

An LED is connected to pin 9.

.

Software setting.

// variables for sensor values
int sensorValue = 0; // a variable for the sensor

// this part just run once
void setup() {
Serial.begin(9800); //initiate a serial connection
}

// this part will run forever.
void loop() {
// read the value from the sensor:
sensorValue = analogRead(A0); //using pin A0
Serial.println(sensorValue); // the sensorValue will be printed on Serial window.
if (sensorValue > 80){ // 80 is a sensitivity value, play with it.
digitalWrite(9, HIGH); //using pin 10,
delay(100);
}
digitalWrite(9,LOW); // using pin 10, turn off the LED
}