I'm using Adafruit 16-Channel 12-bit PWM/Servo Shield with Arduino Uno controller

In setup() I have a number of default positions with PWM commands for motors with plug of USB to PC and turning on

I'm trying to figure out, how to avoid setup() commands, or any other signals during process to servos, in case if shield is not powered from power adapter, which is 6V 8Amp in my case, to not send signal to servo while it is not powered by power supply

migrated from electronics.stackexchange.com May 19 at 19:29

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • Have you thought of using an input pin to sense the voltage of the power adapter? You only have to isolate it from Vcc with a diode (as long as the voltage of the adapter is not higher than the Unos 5V. In that case you also would need a voltage divider. – chrisl May 19 at 19:47
  • @chrisl Hello, and what is the program part in this case, since I need this condition in sketch code. It would be very useful to find some more detailed guide on this task – viktor80 May 20 at 3:24
  • The only releveant code here is to use a value = digitalRead(pin_number). Youc an then do whatever you want with this, for exmple check in an if statement, if the result is HIGH or LOW by doing if(value){...} else {...}. I don't know, what I should write there in my answer. – chrisl May 23 at 13:34
  • @chrisl Yes, but I could not yet use this scheme to check result. As I've said below, it is not enough voltage with using of diode – viktor80 May 25 at 7:45

I would propose a circuit like the following:


simulate this circuit – Schematic created using CircuitLab

The voltage divider (consisting of the resistors) will divide the 6V to 5V for the Arduinos digital input. The values are not critical, they can be made higher, but maintain the relationship to still get the 5V. The diode will prevent current to flow from the shield into the voltage divider, when the shield is powered through other means. Now you can simply do a digitalRead() on the corresponding digital input pin of your Arduino, to check, if the power was applied.

Please notice, that the diode will reduce the voltage a little by it's forward voltage (depends on the diode). But that shouldn't be a big problem.

  • Thank you for answer. Can you clarify, if this way I could monitor power to the servos using one of "digital input pins" with resistor divider to divide that down to 5v or less for the Arduino Uno, what is a difference of using "analog pin" in this case, I found number of close guides: 1. Measuring DC Voltage 2. Arduino Battery 3. Energy meter – viktor80 May 21 at 17:09
  • From your question I assumed, that you use a normal power adapter, which means, that the 6V for the shield are already regulated beforehand. I think of a wall wart. In this case there are inly two possibilities: 6V or no voltage at all. Then the digital pin is sufficient. If you have a battery connected there and want to also sense the low voltage case, you can use an analog pin. – chrisl May 21 at 17:43
  • Hello, I could not yet use this scheme to check result. Something is incorrect for particular shield. I've soldered scheme exactly as you shown, 2 resistors 1.0 and 5.07, diode 1N4148. Without anything power jack shows 6.56V, shield turns on. Through scheme voltage runs from 6.29 to 6.52V, shield does not turns on, seems like it is not enough voltage – viktor80 May 25 at 7:40
  • The shield should also work with voltages down to 5V. Is the green LED on the shield on? Does it work, if you bridge the diode? Is it mounted the right way? (Putting it in reverse will block the voltage to reach the shield) – chrisl May 25 at 8:34
  • Yes cathode (pole with black line) directed with output wire to the shield, should prevent flow from the shield into divider. Anode pole directed to 1kΩ resistor from plus. Voltage from VCC and GND runs 6.18, 6.29, 6.52V... Green LED on the shield off, shield does not works. Without scheme direct meter test shows 6.56V, green led on, shield works. I did not tried bridge the diode – viktor80 May 25 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.