Arduino - Detect external power - arduino

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).

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.

Problems with pins for interruption and motor DC - Arduino UNO

I am working in a project which requires me to read the velocity of a DC motor with a quadrature encoder. I am using the Arduino UNO board and for some weird reason the motor just works if it is connected to the pins 2 and 3. However this pins are reserved for the interruption (where I intended to connect the encoder). How could I solve this problem?
Assuming the arduino can provide enough current, you should be able to run the motor from any output pin, check out this diagram for reference. You should also make sure you have the necessary protection circuits in place. This is a good starting point: https://create.arduino.cc/projecthub/licensedGeek/controlling-a-dc-motor-from-an-arduino-101-board-f4954b

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 Input pin from external system

Is possible for Arduino to receive a 5V into a inputPin from a external battery?
If I have a system that has it's own power supply and after an event fires 5V. How can Arduino read this input?
This is an electrical problem, no software issue I presume.
Here is how to proceed:
1) Make sure both boards have the same ground (connect GND together and make sure there is no conflict)
2) Connect your output to an input on the Arduino board (pin 2 e.g.). This connection is preferably done using a resistor, 1 kOhm will be ok.
On software side, just set this pin as input pinMode(2,INPUT); in setup() and then get its value status = digitalRead(2); in loop().

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

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.

Resources