Jason (jcreed) wrote,

Two semi-successful little arduino projects this evening.

1) I was able to get an off-board LED to fade on and off using the arduino's PWM analog output pins, using a transistor to gate 3V coming from a couple of handy AA batteries.

2) I was able to get my stepper motor to complete a full turn, but only in the most ridiculous way.

So I know I bought four transistors, because I can plainly see four individual little plastic baggies they came in, but I could only find three of the transistors. So I hooked them up like this:

How Not To Control A Stepper Motor

and set the arduino to do the appropriate little bitwise dance as specified by my motor's datasheet, at least over the three out of four bits available to it, 500ms per step.

...and blink the onboard LED in time to how the fourth bit should go.

...and then I manually closed the switch to drive the fourth half-coil in time with that LED.

...and by "closed the switch" I mean poked the wire into the breadboard and removed it. Because I don't actually have any switches lying around.

Anyhow it worked! It's just total hax is all. If I get a fourth transistor tomorrow I suspect I can get it working properly.


Oh oops I used NPN symbols in the schematic when I meant PNP. Whatev. You say potato-type doped silicon, I say... notato-type doped silicon?


Honestly I'm kind of confused by the 1K resistors separating the transistors from my microcontroller. On the one hand, it makes perfect sense that I want to protect my precioussss microcontroller from who-knows-what voltage fluctuations happening on the far side of them drawing too much current from it. Indeed, the only reason I put them there is out of paranoia and cargo-culting from some stepper control schematic I saw once during internet research on the topic.

But I don't see how the transistors actually get successfully turned off when the arduino asserts 5v on its output pin. I want to think that there's going to be a big voltage drop across that resistor because it's the only resistor in sight. If I had a circuit with just a DC power source and a resistor, the resistor would drop the entire voltage. Ohhhhh but the base current is supposed to be relatively small for a transistor. So the voltage drop is also relatively small. Ok. Derp. Thanks, livejournal rubber-duck debugging.
Tags: arduino, electronics, motor

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded