Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wrote some code on the Arduino and it works perfectly fine when powered by the USB. However, when I switch to 9V DC, the sketch does not run. I have tried various things including putting a 10k ohm resistor between RX and TX (Digital 0 and 1). I tried to connect both of them with a simple wire (no resistor). I finally tried connecting RX to ground both with and without a 10k ohm resistor in the path.

I should note that I have an arduino uno, so I have been following the information from Vilros's website. However, the advice hasn't worked for me and I do not know what to try now.

Can anybody suggest how I may get my sketch on the arduino to work when the arduino is not connected to the computer?

Edit, more information: As far as I've tested, the sketch is fairly robust. The board seems to be running on all of the 9V power (when I disconnect the USB it remains powered on). I do not have it connected to the Vin pin though, I have the 9V connected to the DC power supply outlet. The battery is perfectly new.

share|improve this question
    
Does the sketch fail in some way? Or the board is not running at all on the 9v power? Is the 9v connected to Vin? Is the battery fresh? There's not enough information here to help you. – JRobert Apr 10 '15 at 23:53
    
As far as I've tested, the sketch is fairly robust. The board seems to be running on all of the 9V power (when I disconnect the USB it remains powered on). I do not have it connected to the Vin pin though, I have the 9V connected to the DC power supply outlet. The battery is perfectly new. I will add all of this information to my original post. – ArduinoNovice19 Apr 11 '15 at 0:02
2  
Why did you try to connect RX and TX together? I'm not sure what that would achieve. – Peter Bloomfield Apr 11 '15 at 0:17
    
I don't know. The website just said that it would fix the problem. – ArduinoNovice19 Apr 11 '15 at 0:25
    
Please provide links to what you are talking about. You did not even mention what your sketch is supposed to do! This RX/TX connection seems also a complete stupidity? I'd be really curious to know what purposes it serves! – jfpoilpret Apr 11 '15 at 6:40

Please try to power your arduino from a 9V battery. Simply connect the terminals of the battery to the barrel jack (or cut an old wall wart if you have one and make an adapter). It's possible that your 9V wall wart source is too noisy. If the project runs using the battery, try looking for a different wall wart, or add a bunch of capacitors between 5v and ground. (One 100uf and a few smaller ceramics should do the trick)

share|improve this answer

I wrote some code on the Arduino and it works perfectly fine when powered by the USB. However, when I switch to 9V DC, the sketch does not run.

(1) The meaning of

" ... I do not have it connected to the Vin pin though, I have the 9V connected to the DC power supply outlet. ... "

is unclear.

If by "DC outlet" you mean DC INLET where you would usually connect a plugpack/wallwart ... supply, then that should work. Anything else may be fatal. Why not connect to Vin? Vin is the ideal and correct place to connect a 9V battery.

(2) You do not say what the 'sketch' does or uses or expects. If eg it expects or needs a USB connection then it will (of course) not work.

You say that the UNO "still runs" - but, what does that mean.

Run the examples / basics / blink program with USB and without.
Does the LED blink the same in both cases?
If so, the problem is more liable to relate to the USB connection than to the powering.

You can run other sketches to see if they operate with USB & 9V powering. Ones that do NOT access tx/rx are best for checking as they are less liable to interact with the USB port in some uncertain manner.

Report back.


Blink.ino

void setup()   
{  
    // initialize digital pin 13 as an output.  
    pinMode(13, OUTPUT);  
}  

void loop()   
{  
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)  
  delay(1000);              // wait for a second  
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW  
  delay(1000);              // wait for a second  
}  
share|improve this answer

In my project adding a Schottky diode too +5v line solved problem. You can use standard diode but has higher forward voltage drop

share|improve this answer
2  
A "shortly" diode? Can you expand on your answer a bit? – Nick Gammon Nov 8 '15 at 8:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.