Assignment 5: High(er) Voltages and Transistors
Feel* the sensation of a cool, summer breeze..
*Must be one inch away from the fan.
February 20, 2021
This assignment called for us to use a transistor to manipulate voltage. I wanted to make a remote-controlled fan, which required an IR setup and the DC motor. I was really excited to play around with my brand new, shiny IR receiver, and got to work immediately setting up the code.
Code for the IR Receiver and Fan Motor
The code was confusing at first, as it required me to digest and understand the IR Receiver library that I used. The example setup helped me gain a rudimentary understanding of the idea here, and that was good enough for the purposes of my circuit.
Most of the code is to set up and watch the IR remote for active input. The last few lines of the code take in the value gathered from the remote, then assign it, constrain it, map it, then output it to the motor.
Making the Circuit Schematic
The circuit schematic was pretty straightforward; the IR receiver sends a signal to pin 11, and the motor is wired using a transistor and flyback diode setup that we learned from class. There are no resistors in this circuit; honestly, this kind of made my day, as I didn't have to go and figure out what resistances I needed. I could be completely wrong and need a resistor in some fashion, but from the class examples and my knowledge of the IR receiver and fan motor, this seemed to be okay.
Crossing my fingers that my table doesn't light on fire
Acknowledgements of High Voltage
My IR receiver was independently connected to 5V from the Arduino, and hooked to an independent ground. This prevented any potential noise from the motor circuit from interfering with the IR receiver capabilities.
My motor and transistor were connected to a 9V battery, which meant that was the maximum my motor circuit would see. I'm not sure why in the examples I don't see a resistor; is it because the transistor does something special? Or does the motor circuit not need a resistor in order for current to be calculated? In any case, the current to me is unknown: probably a no-no. However, there does appear to be some resistance, otherwise there'd be no current. I'm not quite sure what to make of it. Regardless, the circuit seemed to get a stamp of approval, so with the flyback diode I was good to go. The flyback diode prevents any current created on power down from traveling back upstream.
After putting off building the circuit, it was time. I was really nervous about wiring everything together; the fact that my last IR receiver did not go over super well made me apprehensive about hot-wiring. I made sure that all components were situated and double checked everything was in order before plugging it in. After bracing for metaphorical (and possibly physical) impact, I plugged in the battery and...
It worked! Just kidding; this was acutally after hours of troubleshooting. The problem was that the IR receiver would respond to the first input, and then freak out and not respond to any remote input. At first, I thought it was my code, then I thought it was my motor setup, or that there wasn't any resistor to limit current.
In an act of desperation, I moved my IR receiver ground wire from the general ground line I had my other components attach to to an independent ground. For some reason, this did the trick. I have no idea why sharing ground would interfere with the IR receiver, but one thing I know for sure; sometimes, don't question the good things in life.