Using Battery with HC-SR04 UltraSonic Sensor and Stepper Motor

Hello,

I am making a robot and am using an HC-SR04 sensor to take in the distance from the sensor to the object it is sensing. After getting that data, I want a motor to run if the distance is greater than 6 cm (this is just for testing). So, I wrote the code (below) and hooked everything up in the diagram (also below). When I use my PC to power the Arduino, everything works perfectly. The problem comes when I try to use a battery. When I do, the Arduino powers up, but nothing works! Any ideas?

Thanks

SensorTest.ino (2.38 KB)

1 Like

a battery

What type of battery and how is it connected to the Arduino ?

I am using a "Powerfulcell Extra Heavy Battery" model number 1604D 6F22 which is a 9V Battery.
It is connected via my Arduino Uno R3's battery port.

I managed to find the Amazon link:

That looks like a PP3 smoke alarm battery to me

Have you tried measuring its output voltage when on load ?

No, I haven't. I think you're suggesting I should get a new battery? Any recommendations (keep it cheap of course, haha)?

Not a new battery, a different battery. 6 AAs in series works well

Like a battery pack? I'm a little confused

6 AAs in a battery holder is easiest