Need some help here folks. I been working on a simple alcohol (breathalyzer) project. It includes the MQ-3 alcohol sensor from spark fun and 10 leds.
I have:
a 100k pot on the A0 for fine tuning (because the MQ-3 is not a very scientific device)
10 Leds from digital pin 2 to 11.
5 volt reg powering the MQ-3 and ultimatly the arduino too (battery power)
and I think that is about it.
My issue is that I can not get the led on pin 11 to light up at all. I have tested all my hardware.
swapped Leds, wires and even swapped arduinos just to make sure there wasnt something wrong with my D11 pin on my Arduino Uno.
I have deduced that the issue must be somewhere in the code. Being rather novice at writing code at all I need someone here to look it over for me and tell me where my error is. This code compiles on both the Uno and a Duemilanove and does exactly as it should. it will just NOT light up my top most LED on pin 11.
const int analogPin = 0; // the pin that the potentiometer is attached to
const int ledCount = 10; // the number of LEDs in the bar graph
int ledPins[] = {
10,9,8,7,6,5,4,3,2,1, // Here we have the number of LEDs to use in the BarGraph
};
void setup() {
{
}
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}}
void loop() {
int sensorValue = analogRead(A0);
//This is the code to light up LED's
int sensorReading = analogRead(analogPin);
int ledLevel = map(sensorReading, 500, 1023, 0, ledCount);
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
if (thisLed < ledLevel) {
digitalWrite(ledPins[thisLed], LOW);
}
else {
digitalWrite(ledPins[thisLed], HIGH);
} }}
If any further clearification is needed, just ask. I hope someone can help me out.
Thank you for your snide, curt and boarder line condescending and yet totally correct response
You're welcome. Next time, I'll see if I can't cross the line.
Well then allow me to give you another chance.
I want my LEDs to perform a "boot up sequence"
One reason is so that the MQ-3 has sometime to warm up and the other reason is to look "totally bad ass and impress women"
When I put some "simple"
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
Code in the setup the LEDs are not very bright at all. Once the loop is running the LEDs are at full brightness.
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
Code in the setup the LEDs are not very bright at all.
Before or after the pinMode() statements that declare the pins as output? Before would be my guess, based on the symptoms you describe. If that is the case, move them after the pinMode statements.