Ps4 controlled arduino car won't function as intended

Hello, everyone! so I have been fooling around with Arduino for the past few months now and actually been trying to create a robot as a personal and school-based project. The basics of it are using a ps4 controller to control the Arduino "car", I say "car" because it is scraps from a car kit that I am using to put into my R2D2 robot. I am using a USB host shield, USB Bluetooth dongle, Arduino UNO, H-bridge, and two motors as well as the board that came with the kit. The problem I am now running into is, the motors won't spin when the joystick on the ps4 remote is tilted and any direction. There is a piezo buzzer under the board that changes pitch whenever the joystick is tilted, this gives me the indication that maybe the signals aren't reaching the H-bridge. I have a 9v battery connected to both the Arduino and the H-bridge so I doubt a lack of energy is a problem plus when I was toying around out of boredom I noticed that when I placed my finger on certain contacts the left wheel would spin but won't stop or listen to the inputs from the ps4 controller.

usb host shield: Amazon.com

usb dongle: Amazon.com

Arduino car-kit: https://www.amazon.fr/UNIROI-Infrarouge-Ultrasonique-Évitement-Télécommande/dp/B07CWS344R/ref=sr_1_1?ie=UTF8&qid=1529574678&sr=8-1&keywords=uniroi+arduino

It sounds like you're trying to slap together the whole project in one go. That never ends well. The key to success is to be methodical. Break the work down into individual parts and get each part working before moving on to the next one.

  • Write a sketch that beeps the buzzer.
  • Write a sketch that spins the motors in each direction.
  • Write a sketch that prints the reading from the PS4 controller to the Arduino IDE's Serial Monitor.
  • ...and so on if there are other parts to the project.

These sketches will teach you how to use each part, and verify the part is working correctly. Once that is done, you are ready to start writing the code that uses the parts together. As before, carefully test the code as you write it, making sure it works perfectly before moving on to the next step. Add Serial.println() calls at strategic points in your code so you can get some debug output while the program is running.

Thank you for your reply! I actually got to this point by accident believe it or not :smiley:

besides that, the way I usually learn is by working backward that's why it sounds like I am putting everything together at once. I know it's a bad habit especially for a problem like this but I will try to update you guys and troubleshoot each part. Thanks for the advice!

"I have a 9v battery connected to both the Arduino and the H-bridge so I doubt a lack of energy is a problem "

If those are the 9v smoke detector type batteries, you will need to do better on that.

Alright so I checked the H-bridge for connectivity issues, and I found that one motor might be receiving more voltage than the other ( can't confirm because I left my digital multimeter at school) but the left motor that I mentioned before, when the h-bridge is connected to a battery, would just run regardless if the code told it to or not. I used a demo I saw online using an analog stick to test this. Also when it is turned backward the motor does spin back, when turned left neither motors spin and when going in reverse both motors just stop. The right motor only turns on when turning the analog stick to the right.

example demo used:

If those are the 9v smoke detector type batteries, you will need to do better on that.
[/quote]

the thing is I looked up how much voltage each board drops and saw the h-bridge drops anywhere from 3-4v, leaving me with 5-6v to work wit, or rather drop. the whole circuit seems to work with a simple 9v battery. If you have any information or input you'd like to add to why you think it isn't sufficient please don't hesitate to correct or inform me!

"If you have any information or input you'd like to add to why you think it isn't sufficient please don't hesitate to correct or inform me!"

The board will probably run on the 9v battery for a while, but the motors may discharge it with in a matter of minutes. You may need to get/make a battery holder and use 6 AA batteries in series for the motors.

9v smoke detector batteries are designed to provide a very small current for a long time.
You know, like in a smoke detector.
Ask them to run a motor with its larger current draw and the voltage sags from high internal resistance.

9v smoke detector batteries are not suitable for running cars around.
Use better batteries. 6AA would be better for you.

What if I want it to be rechargeable? The 9v battery I have is rechargeable through a mini USB, would there be a good alternative to the battery I have? I just dont want to constantly swap out batteries whenever they die.

There is at least a gazillion rechargeable battery solutions out there.
Yes, you can use rechargeable batteries.

What are you needs?
If this is a proof of concept/get a passing grade, use alkaline non-rechargeable.
If this is a project to make a car that will be fun to play with long term, use a battery and charger used by similar commercial radio control cars.

If it is somewhere in between, consider rechargeable AA batteries.

Run time, voltage, physical pack size. These are the common constraints that affect battery choice.

This is for a personal/ class project. I want to get into computer engineering and I like to challenge myself, making the robot rechargeable is one of those challenges I set for myself and my professor is holding me to it. As for the requirements, the battery needs to be able to power the arduino uno, the USB host shield, h-brdige with attached motors, and a couple other devices such as a motor drive, pixy cam, wifi cam, and USB bluetooth dongle. Yes I know it's very ambitious but like I said I enjoy the challenge and lessons I learn through this. I did some research on the commercial batteries used for rc cars and could only find 5 piece AA batteries instead of the 6 that I need. The reason I asked if there was an alternative (very broad question in foresight) was because I wanted to know if there was a lithium battery I could use that gave me the adequate voltage and amperage while also being rechargeable, this idea is reinforced seeing how 6 piece recharable battery packs dont come standard.

If you need the individual parts and their energy requirements to then make an estimation or recommendation then just let me know and I will happily supply them!

The car kit that you linked to in the first post shows this (google translate)
Safer and more powerful: the robot car has rechargeable Li-ion batteries 2PCS 3.7V 14500 with protection circuit board, capable of providing more protection to the children who build the robot project, while having fun.
I assume that the kit came with the batteries, a holder and a charger. If so, use them.
If not, any 2 cell LiPo battery would work. Get one with at least the same capacity as the ones for the kit, 14500mAh. You will need a charger.
If you are going to buy batteries and a charger, let us know.
I order a lot of LiPos and chargers from Hobby King but there are many other places (AliExpress)

14500 is almost certainly the size (like 18650) not the capacity. Most 14500 Li-ions are around 750-850 mAh. So something like a 2S 1000mAh Lipo would probably do the job too.

Steve

"I did some research on the commercial batteries used for rc cars and could only find 5 piece AA batteries instead of the 6 that I need."

I think the bottom line is what types of rechargeable batteries and chargers do you have access to. Do you have access to rechargeable AAA, AA, or 18650 batteries and rechargers for those types of batteries? If you don't have access to a rechargeable battery and a recharger that fits it, then that part of the project will will not happen.

Alright so the kit I took parts from did not feature the battery, its was an unfinished project that my professor gave to me to help me out. As for charging the battery I would like to do it through a micro USB, that is a whole other problem in of itself (I bypassed this by buying a recharable 9v battery mentioned in the first post that had a micro USB connection). Also I had a question about the amperage, you mentioned that 750mAh to 800mAh would do just fine but I looked up the requirements for each device in my project and found that the arduino with the shield aswell as the Hbridge work best when they are fed 2Amps each. Now I don't know much about batteries seeing how I am a novice but can someone please explain this to me? Is there something I am missing? I'll try to do my own research in the mean time so it's easier to explain. Thank you!

Found this device that may solve all my power problems. I know I didnt mention I wanted a power bank because I dont but I figured why not? Just another perk to add on.

https://www.google.com/url?sa=t&source=web&rct=j&url=https://www.amazon.com/Mobile-Battery-Charger-Module-Protection/dp/B07D6M2LCS&ved=2ahUKEwjJ66qjg9joAhWBmXIEHbZLDhQQFjAAegQIARAB&usg=AOvVaw2gifpAJuLYLwM2Txi-XJDy