Controlling the speed of motors using Arduino Uno without using analogWrite? - arduino

I need to control the speed of my autonomous Arduino Uno robot, but I have been restricted. I can not use any MCU libraries such as analogWrite, any hardware devices or modules from the MCU (timers).
I have thought of just turning the motors off and on at very small intervals and putting that in a loop. But I am trying to find a more efficient and clean way of doing it. I need to be able to control the speed to 75%, 50%, and 25% of the normal speed, and turning the motors on and off, it gets complicated.
How do I control the speed of the motors in a more efficient way?

You said you have some very restrictive conditions:
I can not use any MCU libraries such as analogWrite, any hardware devices or modules from the MCU (timers).
Get a motor controller with a serial interface and whenever you want to change the speed, bit-bang a few serial bytes out to it. You just need to connect the Arduino's GND to the controller's GND, choose an Arduino pin to be the TX line, and connect that pin to the controller's RX line. Then use digitalWrite and delayMicroseconds to bit-bang some serial bytes.

Related

Intercepting a signal with ESP32/Arduino - resistor placement

I'm hacking a callbell to connect an ESP32 in order to send me a Telegram notification. The software side is OK but I'm having difficulty in detecting when the callbell goes off. When it is triggered, 5 LEDs flash. They are connected in parallel with +5V at the anode and via a 2K resistor into a pin on an unmarked IC.
Ideally, I'd solder a wire between the resistor and the IC to detect the falling edge but there is very little space. Between the LEDs and the resistor there is sufficient space to attach a lead but I can't make it trigger an interrupt. My question is, can I add my own 2K resistor between this lead and the GPIO pin?
circuit diagrams
Edit: managed to solder a lead between the resistor and the IC. Project deployed and works well. Thanks for your help
Yes you can. Just make sure your device has a common GND wit your ESP32. Also measure the voltage there and check the required resistor resistance..
EDIT: If I am right, this will connect GND to the digital pin, that should be pulled HIGH, then you can detect the GND.
Also connecting a transistor to switch 3.3V when gnd is given by the IC can be a good solution.

how to connect ledstrip to arduino

On Adafruit there was an example on how to connect a ledstrip to an arduino, but it said "For longer strips requiring more than 1A, wire power directly to the strip, then run power and ground wires back to the Arduino." I didn't fully understand it so i made a sketch on circuits.io . Since there isn't a normal ledstrip in there i used a RGB to show my sketch, but i can't test it. So before i fry my arduino or ledstrip can someone explain if this is correct or if it needs to be changed? Also can i connect everything on a breadboard or not, since the higher voltage and amp.
https://i.gyazo.com/27e9a6527805b6e4e898a8f32f66de61.png
That would work.
I believe this is the same as this https://learn.adafruit.com/rgb-led-strips/usage
about the breadboard it really depends on the breadboard they can vary from cheap ones 0.5A to 2A is usually the maximum current rating for a good solderless breadboard
Here are what you need:
Your Arduino.
An external power supply. Get something like this for your external power suply.
You led strip.
Connect:
PWM pulse of Arduino -> Data IN of led strip
All GND togheters
5V output of external power supply-> VCC of led strip
Computer -> USB -> Arduino
External power supplies give you high current levels, perfect for many leds. Dont worry about your breadboard melting, it should be able to handle it.

Arduino not working the same when powered with battery, not usb

So, I'm building an Arduino toy car. It runs with 4 motors and has 2 color sensors and 8 IR sensors. It must work on battery because i don't want it to be hooked to USB all the time and motors require much more current than USB can provide. So here's the problem...
When I have my arduino powered with USB cable or USB cable and battery, it works perfectly, but when I have it powered only on battery (7.2V), 4 LED's in the left color sensor glow dimmer, and the right one doesn't even work.
I should point out that some of the pins of color sensor that should be plugged in 5V or GND are plugged in digital output pins set on HIGH or LOW.
The arduino i'm working on is Arduino Mega 2560 and color sensors are TCS230.
I think you should measure supply current of the board and then check if your battery is able to provide such value. Also try to feed the board from external supply through wall adapter connector (or Arduino's Vin terminal). The idea is that you may need higher voltage and(or) current, then 7,2V.
Check to make sure you have the correct resisters values in place to drive the LEDs. You can sometimes get away without doing so but it is iffy and you can sink a lot of current you don't really need to. I found this link, "Driving LEDs with an Arduino".

Arduino voltage regulator power consumption

I am trying to create battery powered sensor from Arduino mini.
I am allready aware and I am using sleep and clock regulations, but my concern at the moment is voltage regulator of the board. I am using HM-10 as transmitter and it works well.
I know, that the board is using linear voltage regulator (7805?) which is not efficient and consumes power even if the board is not consuming power. I do not like this.
I would like to know if there is a possibility of bypassing this regulator and powering board directly from battery?
I would like to prevent soldering...
You can't power it directly from a battery, because batteries do not output a constant voltage.
You can use a switching regulator like the LM2936 and power your Arduino through the 5V pin. That would bypass the onboard regulator and supply your Arduino with a nice steady and efficient 5 volts. Switching regulators use very little power on standby, and are extremely efficient.
Just make sure to check the output voltage of your regulator before you connect it to the 5V pin on the Arduino - anything more than 6V on that pin will likely smoke something, since you are bypassing the onboard regulator and all of the protection circuitry that goes with it.
There are plenty of switching regulators to choose from - the LM2936 is just one I happen to have used before - google "switching voltage regulators" and find one with specs that meet your needs.

Arduino - Detect external power

I have an external power source (6v) that is connected to a motor and a servo, and on my arduino board I have a couple of LEDs which are powered by the onboard 5v. The external power is connected to a switch so I can turn on the motor and servo (to save battery). My main board just blinks the different LEDs. What I want to happen is that the moment my external power is switched on, the LEDs stop blinking and the code to move the servo and motor is executed. As a result I have a boolean called intro. When it is true, the LED code executes, when it is false the motor and servo code will execute. The only problem I am having is that how can the Arduino know if the external power is switched on so that the boolean can be set to false? Is there a way that the arduino can detect if the external power is on (for example checking the pins of the motor/servo?)?
The general idea is to connect the external power to an I/O pin so you can read its status. You'll also want a pull-down on the I/O pin so that it doesn't float and give random values when power is not connected.
Don't connect 6V directly to an Arduino I/O pin, it will be far enough above Vcc that the clamp diodes on the pin will activate. A series resistor like 10K to reduce the clamp current will probably be OK but still isn't the best design practice. I'd recommend a 3V3 zener diode clamp such as that on this page:
http://www.kevinmfodor.com/home/My-Blog/microcontrollerinputprotectiontechniques
Check the max input voltage on the IO pins, but you should be able to connect the external power to a pin and drive an interrupt.
The interrupt can then be used to decide if the power is on (rising edge) or off (falling edge).

Resources