Hello, I am finishing a project for a gas sensor + buzzer.
I test my sensor on site, calibrate with the USB port power.
After I am done I use my stationary ACDC Adapter for arduino, but the arduino won't stay ON.
I tested with another arduino same result, so I suspect it's the coding ??
Steps:
testing ACDC Adapter with new arduino without code (blank) - BOOTING, POWER ON, OK
Uploading Code, inserting Adapter while the USB is in the Arduino (or not both tried) - NOT Booting, light blink once and the unit won't stay on.
Any clues?
Thanks
/* Testing MQ-2 GAS sensor with serial monitor
Suitable for detecting of LPG, i-butane, propane, methane ,alcohol, Hydrogen or smoke
More info: http://www.ardumotive.com/how-to-use-mq2-gas-sensor-en.html
Dev: Michalis Vasilakis // Date: 11/6/2015 // www.ardumotive.com */
const int gasPin = A0; //GAS sensor output pin to Arduino analog A0 pin
//Example code KY012 active buzzer
int speakerPin =8;
void setup () {
pinMode (speakerPin, OUTPUT);
Serial.begin(9600); //Initialize serial port - 9600 bps
}
void loop () {
int gasSensorValue = analogRead(gasPin); // read sensor
if (gasSensorValue > 70) {
analogWrite (speakerPin, 255); // Do an off-on pattern starting with off
delay (500);
analogWrite (speakerPin, 0);
delay (10);
} else { // Shut the buzzer
analogWrite (speakerPin, 255);
}
Serial.println(gasSensorValue);
delay(500);
}