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..
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..
//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..
//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);