I don't know.
You haven't told me anything about what is wrong.
(Still wasting RAM though...)
I don't know.
You haven't told me anything about what is wrong.
(Still wasting RAM though...)
The same issue I was having previously, Arduino freezing when I use my remote, like suppose, I clicked the button I have programmed to make the car go forward, the motors will do as I have programmed but when I click other button programmed for doing something else, like to turn left or right and to stop, all the things suddenly stop responding, even the red reset button won't work sometimes, I have to disconnect the programming cable and plug it in again. Although, if I use LEDs instead of motors everything would work just fine.
And yes, I will use that f() marcos to cut down the RAM usage.
Please do help.
What are you using for a power supply?
Since I don't have a battery, I'm using the USB cable used to upload the code to power my project.
And what is the USB cable connected to?
It is connected to my laptop which I use to code the project.
(BTW sorry for not responding quickly, currently am facing restrictions since it's my first day. I have to wait for a couple of minutes before I can reply.)
Maybe you're exceeding the 500mA limit on USB
You could use some serial prints to debug ...
what and which kind of serial print though?
The kind that might indicate where the code is freezing.
So I have figured out where the code is freezing, when I use IR remote, after pressing the button once, which has been programmed for a specific action in the code, either the IR sensors or the Arduino doesn't respond, probably the Arduino since even the reset button doesn't work till a few clicks.
Do you have any solutions regarding this issue?
I have no solutions, only suggestions.
Like an adequate power supply for the motors.
Say, half a dozen AA batteries.
Always the same unspecified specific action?
I have programmed 4 actions for my project, to go forward, to turn left & right, and to stop. I have specified this in my code as well. Now, as per the code, if I I have clicked the buttons that I have programmed one after the other on my IR remote it should work, as it was working when I used LEDs but, when I switched to motors the project ain't working, it gets stuck or frozen after I have clicked one button and continues on.
Don't get me wrong, but is there anyone in the community you know who can help me? Please tell them to see my forum once.
I just brought a 9V battery, it doesn't seem to work.
No, I wouldn't expect it to, if it's one of those little ones that belongs in a smoke alarm.
Why? I mean it supplies 9V still.
9 volts, but at what current?
(Hint: not much)
Ok, I got you. Do you think combining two 9V battery help?
If you connect them in parallel then they will last approximately twice as long
However, twice as long is still not very long
Use 6 AA's to power your project
The main fault of your project is trying to supply the motors from the Arduino's 5V pin.
Any stadard computer / table / smartphone USB-socket is limited to 500 mA.
Whenever anything that is connected to such a socket that tries to draw more than 500 mA the socket shuts off
The 5V-voltage regulator of the arduino has a very limited current too.
Additionally the higher the input voltage the lower the current you can draw.
because all the energy of the "have-to-move-away-voltage" has to be transformed into heat.
This is called dissipation-power.
feeding in 12V to the arduino which means regulate it down to 5V means
have-to-move-away-voltage 12V - 5V = 7V
7V! multiplied with the current you are drawing .
This onboard-voltage-regulator is rated maximum dissipation-power 1,5 Watt
This means
1,5 W / 7V = 214 mA
feeding in 8V regulate down to 5V means have-to-move-away-voltage 8V - 5V = 3V
1,5W / 3V = 500 mA which is the maximum of the voltage-regulator. This voltage-regulator has to supply the arduino itself too. This means you have less than 500 mA at the 5V-pin on the arduino-board.
even small motors draw more than 200 mA under load and especially at the moment you switch them on. In the moment of onswitching for 0,1 seconds the current is much higher. This makes the supply-voltage drop down too much and the arduino is feeded with a too low voltage which makes him hang.
So there are a few things to learn if you are working with microcontrollers:
superstandardised like USB-devices you have to take care about more details than
"does the plug fit into the socket?"
.
.
keeps your arduino alive, because you detect too high currents or too high voltages before they damage your arduino
knowing the basics of Ohms law is a big advantage. (voltage-drop, dissipation-power)
a digital multimeter that is able to measure voltage, current, resistance, capacity, frequency, dutycycle is almost a must and will enable much quicker finding electronical problems
such a 9V-block
So the one and first thing you have to do is ordering such a 6x AA battery-holder
and
for two reasons:
you might think "voltage-drop?" "inner resistance??" What is this guy talking about??
Well I'm just mentioning the basics you have to know to be able to design an electronic project in a way that it becomes a success. You should ask a lot here in the forum to learn these things
And take a look in the hardware basics that are offered on arduino or adafruit.
best regards Stefan
Sir, highly respect your feedback and appreciate you took your time to reply.
Absolutely not sir, you see, I'm in 10th grade so I knew some of the terms you talked about in your reply. There are two main reasons that I might not have been able to identify the causes that was holding back my project from succeeding. Firstly, I'm in 10th grade so my parents are more concerned about my studies so usually they don't buy me stuff like multimeters or other handy equipment which will help me find out the cause. Secondly, there are a lot restriction regarding buying components, I live in India so a lot of stuff isn't available or if it is, it's too expensive.
But I got to learn a lot through your reply, I didn't know stuff like inner resistance of batteries, etc.
BTW, I have posted the same issue on stackoverflow, and they told somethings are wrong with my code as well. I would like to hear your piece on this.
Thank a lot again.
Regards,
Rahul Mishra