Hello. This is not directly a XOD-related question, but I’m honestly not sure where to start looking for an answer to this problem and XOD is what I’m using to program.
I am using an Arduino Uno to control a circuit, and part of that circuit is an electromagnet tied to a button. The behavior I want from this circuit is as follows: When the button is not pushed, the Arduino keeps the magnet on. When the button is pushed down, the electromagnet should cut off. The electromagnet is on its own circuit with its own power source, and a single wire connected from the Arduino’s D13 pin to the base of a transistor turns that E/M circuit on and off. (I did this because the Arduino alone was not providing enough power).
The XOD node setup for this part is simple, just a button node connected to a digital-write. The button goes to the Arduino’s D12 pin, and the electromagnet is controlled by the D13. I do not think the problem is in the code. (Below is not the full code, just the part that is interacting with the E/M):
The problem I am having is that instead of cutting off completely the electromagnet is only decreasing in power slightly when I hold the button down. I’m using it to hold a model car in place on a ramp, then when I press the button it will release and a timer starts. However, the weight of the car will be variable, so the decrease in the magnet’s strength is not always enough to release the car.
I believe this is happening because when the Arduino is writing a LOW state to the EMag, there is still marginal current passing through the wire, which is enough to open the transistor. I’ve fiddled with the resistance between the wire and the transistor, but I’ve ran into the problem of either making the magnet too weak to hold the heavier cars, or too strong enough to hold all the cars, but then it does not decrease in strength enough to release the lighter cars.
TL;DR: Is there a way to guarantee that an Arduino pin’s LOW state is as close to 0V as possible, either through XOD or through a hardware trick? Or do I just have to deal with some marginal current going through it at all times?
The full schematic is here, but the only relevant part is the button off of D12 and the E/M circuit off of D13: