I need help with my Arduino project for school
Hello thanks for reading this😁,
I'm currently making a robot for school that should move his servo motors and must play saved wav files from the SD card, when a letter (for example h) gets sent trough Bluetooth (with HC-05) to the Arduino. My only issue is that for some reason I can't use the HC-05 and the SD Card Memory Modul at the same time. I can use the HC-05 while SD Card Memory Modul is unplugged and the letters arrive at the Arduino and the servo motors will move without any issue. And I also can send letters trough a USB cable connected to my pc, while the HC-05 is unplugged, and those letters arrive to the Arduino, the SD card will play the wav file and will move its servo motors without any problems. But every time I use both at the same time (HC-05 and SD Card Memory Modul, that's my goal) it seems like the letter gets sent to the HC-05 but will never arrive at the Arduino itself. I think the problem could be that the SPI of the HC-05 and the SPI of the SD Card Memory Modul are interrupting each other somehow, but I almost don't know anything about SPI lol😅.
I used Chat-GPT and watched tutorials online but nothing worked for me, I don't know how to fix this issue .
I hope someone in this Discord server can help me with my issue . I would really appreciate it.
The Arduino code is attached down here (it might be a bit messy)⬇
Thanks for helping.😁

49 Replies
right away this is an issue:
you can't use pins 5 & 6 for multiple things
these r not in use right now so its not important I used before that pin 0 and 1 (rx and tx) on arduino uno for the bluetooth module and there is the same issue ofc
not sure I understand, but you shouldn't use pins 0 & 1 on an Uno for BT
okey
0 & 1 are used by hardware serial
I removed trig end echo and bt is on 5 and 6 and I still cant use them both at the same time
could the power supply be to low? I'm using a powerbank to power the arduino with 5V output and 3,1A.
@AnonEngineering so do you got any idea how to make it work?
without the code and wiring you are using? no
The script is that 😁:
https://discord.com/channels/420594746990526466/1370715689928622140/1370715719687213087
And I'm providing my wiring as soon as I'm back at home.
OR YOU CAN JUST USE THIS
the barrel jack requires 7v - 12v in, if that is connected to a 5v power bank that is a problem, it looks like you are trying to power several servos from the Uno 5v pin, you can't do that.
@AnonEngineering ,
Thanks that was the problem. I gave the barrel jack 9V and it works. Last issue is that I'm only able to run the .wav file from letter h and the function hi will never start, and the other letters only work if you don't run h before running them (so theyre functions r working). So the issue must me the SD card. If you can help me with this last issue I should not have any issues anymore. The script is this attached file.
Thanks for helping😊
what calls the
hi
function?that hi function never starts because somehow the wav file stops everything else you can send h again in serial the sound gets player but function hi never starts. The same thing with the other if loops

after
cool.play("abcd.wav");
runs then it'll go to the hi
function
is it playing abcd.wav
?Yes
But the hi function never starts
because my servo doesnt move at all
put a print in the
hi
function, maybe it runs but the servo has a problemYep you are god damn right again its appearing in the hi function and in every other function too.... it should be the servos. Does that mean the Arduino needs more voltage or something else. Thanks for helping. You are helping me so much.
you cannot power servos from the Arduino 5v pin
(that pin can deliver at most 0.5 amps, your servos can easily draw 1 amp each)
from where do I have to power them? From 3,3V?
that's even worse 😉
use a 4xAA battery pack for servo power (look up "Arduino external power")
so something like that?

or just a basic 4xAA battery slot

the breadboard PSU only does 500mA too, use the battery pack (it'll do a few amps peak)
the positive lead goes to servo + leads (only), the ground gets tied to Arduino ground
that way servos draw power from battery, arduino only supplies a low current control signal
Hey,
Thanks for responding. I'll try that as soon as I can. I'll let you know then (sadly I can test that in a week or so).
Does the ground really just get tied to the arduino?
And the arduino ground to the servos?
all things in the project get tied to a common reference point (ground)
Yeah but the servos dont need the battery ground?
Just the arduino's?
yes they do, servo ground = arduino ground
So the ground from the battery is only connected to the arduino to complete the curcuit?
So it has no other practical use
you connect the battery pack ground to both the arduino ground and the servo grounds
battery + goes only to the servo + leads
To both, that was the missing information thx
But maybe we need help later on...
that way the battery supplies the high current to power the servos, the arduino only supplies low current control to the servos
Through the normal pins like 11, 12...
through whatever GPIO pins you chose
Ok thx
here the battery is shown as "Vcc" and "GND"

Yeah than i got it right
Thank u very much again
Hey @AnonEngineering,
We have connected the batteries like u told us to ,and the servo motors are moving at the beginning. But unfortunately our SD Card Module is no longer working (and we migh have other issues aswell). I haven't added all the parts, we have on our circuit on the cuircuit designer, because we still have some unused wires and parts on our circuit board. I will send our circuit
and our updated script in here. I hope you can find some errors we're unable to find. We're almost out of time for the project ,so we really appreciate your help.
Thanks
https://app.cirkitdesigner.com/project/02e643e5-e284-43d1-9caa-d76e4469e8d0
Cirkit Designer IDE
Cirkit Designer IDE is an all-in-one circuit design tool that helps you create and share electronic circuits with ease.

You can't feed the servos 9v for one thing
And I'm on my phone, can't really check code
Thanks for the information. We’re facing another issue and its more frustrating. Its the SD card module. We suspect it may have been damaged during development, as we’re unable to run even a basic test script—neither on an Arduino nor on a Funduino.
We consistently receive the error part of the script in the Serial Monitor, even though the SD card is currently empty and formatted in FAT32.
Here’s the test code:

If the wiring is exactly as depicted it's correct. Try a different SD card.
as Max said, it should be working. your code runs fine in the Wokwi simulator
Hi thanks for responding @max and @AnonEngineering . Yes the SD Card Module was the problem it somehow broke and with the new one I have no longer that issue. But now to the more important part: I think I know what the issue is with the servo motors. As I said they work before I run the command (so before I run the speaker). But after that I've realised it never stops trying to play something (it keeps making a small noice the speaker). So it seems like it's not a voltage problem. More like a SPI or a code problem. But I don't know alot about that stuff. I hope that helps you guys to understand my problem.
Thanks:a_heart:
https://github.com/TMRh20/TMRpcm/blob/v1.3.6/pcmConfig.h#L37-L39
TMRpcm library by default takes control of both pin 9 and 10 and a hardware timer, so it does affect those pins plus PWM output on possibly other pins
you need to chose the pins and configuration very carefully
Oh okay I got it I checked that all out and I've found a solution. We use for the servos timer 2 instead of timer 1 (I've found a libary that does that). Well unfortunately we only have one timer 2 pin that is usable (because we already use pin 11) would ya guys recommend using an Arduino Mega, instead of the Uno even though we had issues with it. Or is there any other solution?
@AnonEngineering @max Hey thanks for helping with all those issues.
We are now on the last step on adding all the arduino stuff into the body of the robot. We haven't reduced the 9V from the batteries that are only get feeded to the three servos, because we had no issue for now. And we were somehow able to power 2 servos, even though we only had only one usable timer 2 pin, that is currently not in use.
Thans for helping

expect the lifespan of the servos to be reduced at 9v
however, if you measure the voltage I bet it's closer to 7v, 9v batteries can't supply much current so the load will drag down the voltage.
Hey, I forgot to mention. Our robot works perfectly now. Thanks for helping😁