Go Down

Topic: Arduino program problem with DC input (Read 3901 times) previous topic - next topic


Oct 02, 2012, 10:27 am Last Edit: Oct 02, 2012, 11:59 am by Analog_M0n Reason: 1

I'm having problems when my arduino uno is plugged in with a 9V DC input.
When plugged with the USB cable, everything works fine.

Here is what my program is suppose to do:
(1) LCD monitor displays: RECYCLE BIN
                                 Let's Recycle
(2) When Capacitive proximity sensor is HIGH, display: Thank You!
                                                                       Cans: (no. of count)

When the arduino is powered by 9V DC:
step(1) is excecuted properly
but when sensor is HIGH, the whole LCD monitor is filled with black squares
when sensor is LOW, sometimes it goes back to what is shown in step(1), sometimes there are black squares on the first row, and sometimes nonsensical things come out.
I also noticed sometimes that the LEDs labled tx and rx lights up.

My program is as shown below:

Code: [Select]
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
const int sensorPin = 7;
int sensorProxCounter = 0;
int sensorState = 0;
int lastSensorState = 0;

void setup()
 pinMode(sensorPin, INPUT);
 lcd.print(" RECYCLE  BIN");    
 lcd.print(" Let's Recycle");
void loop()
 sensorState = digitalRead(sensorPin);
 if (sensorState != lastSensorState)
   if (sensorState == HIGH)
     sensorProxCounter = sensorProxCounter + 1;}  //count increases by 1 when sensor is high
     lcd.print("Thank You!      ");    
     lcd.print("Cans:           ");
     lcd.print(sensorProxCounter);      //lcd displays number of counts
   lastSensorState = sensorState;

Could there be a problem with the board? Or is it just my program? Please assist. Thanks


Looks to me like the 9V DC input is not stable enough.

You should provide the circuit schematics and some more details about the power supply you're using.

BTW, please use code tags.


Oct 02, 2012, 12:35 pm Last Edit: Oct 02, 2012, 12:39 pm by Analog_M0n Reason: 1
I have attached a diagram for my power supply circuit, hope it is acceptable.


The only thing I noticed in your code is an unindented closing brace right after counter increment. But I don't think this has something to do with the behaviour you described.

The diagram looks good to me. Maybe someone here with hw-fu can give you a hint about where to look for potential problems. I would start by checking the 9V line both before and after the regulator with a multimeter when Arduino is running without the usb cable.


Could high current be the cause? There is a current of about 1A when I checked


Could high current be the cause? There is a current of about 1A when I checked

Where did you measure that current ?


At the output of the voltage regulator (Arduino DC input)



IIRC the USB bus can provide 500mA max. current. If the Arduino is drawing 1A off the 9V regulator, how can it function correctly when running on on USB cable only ?


I see, is there a way to reduce the current supplied to the Arduino?


I see, is there a way to reduce the current supplied to the Arduino?

Dunno. Someone with higher hw-fu must step in at this point. I suspect you must supply Arduino with as much current as it needs, otherwise there will be problems. If the Arduino draws too much current the solution is not to give it less, but to understand why and see if it's possible to reduce consumption.
What puzzles me, though, is why it seems the board is consuming more current when running on 9V than when running off of usb power... ?-|


Oct 02, 2012, 05:32 pm Last Edit: Oct 02, 2012, 05:41 pm by wizdum Reason: 1

I see, is there a way to reduce the current supplied to the Arduino?

That would be like draining a patient of blood to prevent them from bleeding to death from a cut. If your Arduino is drawing 1A, then you have a short somewhere. Since that much current would burn out the on board regulator (and the regulator of your computer's USB ports), you probably measured it wrong. You need to put the multi-meter in series with the power supply. For example, disconnect the +9v wire (but leave the ground wire attached), attach it to the negative lead of your multimeter, and then attach the positive lead of your multimeter to the Arduino. It will now tell you how much current the Arduino is drawing.

What type of battery are you using? The 9v smoke detector type batteries are not a good source of power. They are designed to provide all their power in a short period of time. What is the voltage of the battery as measured by a voltmeter?

You are better off using a 6xAA battery pack to give you 9v.

Scratch that, college wifi is terrible, your image just loaded.

What is the voltage going into the regulator (check with a multimeter) and what is the part number on the regulator? Just looking at the LM7809 regulator, the min. supply voltage is 11.5v, you could be dropping below that.


Oct 02, 2012, 07:18 pm Last Edit: Oct 02, 2012, 07:21 pm by MarkT Reason: 1
We need the circuit you built, not just part of it!   Arduino, sensors and all - a photo may be easier.

1A sounds _drastically_ wrong.  You are feeding 9V to the barrel jack?  How are the LCD and proximity sensor powered?  What current do each of those take?

[ BTW that circuit has a serious flaw - there should be a fuse on the +ve lead to the accumulator, preferably close to it - shorting out a large lead-acid battery is a recipe for burnt out cabling, buckled plates, large bangs and can start a fire ]
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


You can't actually measure the current of the 5V output on arduino voltage regulator. What you did with a multimeter was probably causing 1A flowing down the meter. How did you make that measurement?
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter


The LCD connections are stated below
1|VSS| -> Arduino GND
  2|VDD| -> Arduino +5v
  3|VO | -> Arduino GND pin
  4|RS | -> Arduino pin 12
  5|RW | -> Arduino GND - pin can be conected to 11. But Ground was used here.
  6|E  | -> Arduino pin 10
  7|D0 | -> Arduino - Not Connected
  8|D1 | -> Arduino - Not Connected
  9|D2 | -> Arduino - Not Connected
10|D3 | -> Arduino - Not Connected
11|D4 | -> Arduino pin 5
12|D5 | -> Arduino pin 4
13|D6 | -> Arduino pin 3
14|D7 | -> Arduino pin 2
15|A  | -> Not Connected
16|K  | -> Not Connected

Updated circuit diagram.

Capacitive proximity sensor requires 12V to operate.

The 1A measurement was made using a multimeter at the 9V output when it is not connected to the Arduino


The 1A measurement was made using a multimeter at the 9V output when it is not connected to the Arduino


Nonono! When the multimeter is in amp-mode it behaves like a straight wire. If you connect the multimeter terminals to the power supply + and - like you would when measuring voltage, you're basically making a short circuit! Luckily the 9V regulator can't give more than 1A and the multimeter could cope with it. Had you made this "measurement" on the battery you would've damaged the multimeter or at least burnt its protection fuse!

What you need to do is connect the multimeter like it was a simple wire going from the 9V regulator to the Arduino. For example, multimeter + to supply +, multimeter - to Arduino +.

Go Up