Project 13

can u guys help me with this..

http://www.earthshineelectronics.com/files/ASKManualRev5.pdf

i currently doing the project 13 in this ebook..but i want to change the LDR sensor to smoke sensor..i want the LED to light when the sensor detecting smoke..i'm using QM-NG1 smoke sensor..i need help in the schematic and the coding..i'm really2 noob in arduino..i am a beginner..

You've figured out that you can post links, so where's the link to the sensor you are using?

We can't help with the coding until we know what kind of data the sensor returns, and how it should be connected to the Arduino.

this is the manual for the sensor...

and this is the datasheet...

http://www.dfrobot.com/image/data/DFR0049/QM-NG1%20Specification.pdf

So, it's connected to the Arduino as shown in the sketch in the first link, and read just like an LDR.

yeah..i think so..but when i change the LDR with the sensor..i cant see any difference...i dont know what wrong with the connection..that why i need help..

We need to see some code, then.

How are you testing the sensor?

//Project 13 - Light Sensor
// Pin we will connect to LED
int ledPin = 6;
// Pin connected to LDR
int ldrPin = 0;
// Value read from LDR
int lightVal = 0;
void setup()
{
// Set both pins as outputs
pinMode(ledPin, OUTPUT);
}
void loop()
{
// Read in value from LDR
lightVal = analogRead(ldrPin);
// Turn LED on
digitalWrite(ledPin, HIGH);
// Delay of length lightVal
delay(1000);
// Turn LED off
digitalWrite(ledPin, LOW);
// Delay again
delay(2000);

}

i think i want to change the default code that provided in the ebook..change the LDR to smoke, but i want to make the LED will only light when the sensor deteecting smoke..when it is not detecting smoke, i want the led to be off...

how do i test the sensor?i am using some cigar smoke..

void loop()
{
 // Read in value from LDR
 lightVal = analogRead(ldrPin);
 // Turn LED on
 digitalWrite(ledPin, HIGH);
 // Delay of length lightVal
 delay(1000);
 // Turn LED off
 digitalWrite(ledPin, LOW);
 // Delay again
 delay(2000);
}

Where do you use the data retrieved from the sensor? Where do you even print it?

the code that i provided is the code for the LDR sensor, i want to know what should i change or add in the code..that why i need help..i am really new with the arduino and C programming..

The comment says that the delay() time is based on lightVal. Instead, it is a constant.

Add:

Serial.print("sensor value: ");
Serial.println(lightVal);

after the digitalRead statement. Add:

Serial.begin(9600);

to setup.
Open the Serial Monitor to see the output.

where should i add those code?

where should i add those code?

Right where I told you to:

//Project 13 - Light Sensor
// Pin we will connect to LED
int ledPin = 6;
// Pin connected to LDR
int ldrPin = 0;
// Value read from LDR
int lightVal = 0;
void setup()
{
// Set both pins as outputs
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// Read in value from LDR
lightVal = analogRead(ldrPin);
Serial.print("sensor value: ");
Serial.println(lightVal);
// Turn LED on
digitalWrite(ledPin, HIGH);
// Delay of length lightVal
delay(1000);
// Turn LED off
digitalWrite(ledPin, LOW);
// Delay again
delay(2000);

}