Trinket and DC motor

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
jbc
 
Posts: 159
Joined: Wed Aug 14, 2013 7:18 pm

Trinket and DC motor

Post by jbc »

I am looking for a simple (and cheap) way to turn a motor on based off of input from a sensor.
I was thinking of attaching a DC motor https://www.adafruit.com/products/711 to Trinket 5V https://www.adafruit.com/products/1501.
Can I run a 9V battery to the trinket to control the DC motor when the sensor is triggered?

This motor nor the 9V battery are a must. I can use AA batteries and another DC motor (tho the price of this one is attractive).
jbc

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: Trinket and DC motor

Post by adafruit_support_bill »

You can't switch a motor directly from a Trinket output. But for a small motor like that, you just need a small transistor. This guide shows how to wire and program it for an Arduino. You may need to use a different pin, but the same circuit and code should work on the Trinket.
https://learn.adafruit.com/adafruit-ard ... -dc-motors

User avatar
jbc
 
Posts: 159
Joined: Wed Aug 14, 2013 7:18 pm

Re: Trinket and DC motor

Post by jbc »

AFTER LOOKING AT THAT GUIDE IT LOOKS LIKE i COULD SOLDER THE PARTS TOGETHER to avoid a a breakout board no?
It looks like it.

Would the trinket and 3 AA batteries give that motor the juice it needs?

Or would the 3V trinket and a 9V battery work better?

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: Trinket and DC motor

Post by adafruit_support_bill »

You could probably wire it direct. Just be careful that the component leads are not subject to a lot of bending. They will break if subjected to repeated stress. You can solder the diode between the motor terminals. The transistor is a little trickier.

3xAA or 4xAA will work much better than the 9v. A 9v will give you more voltage to start, but it doesn't have much capacity and will fade fast driving a motor.

User avatar
zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: Trinket and DC motor

Post by zener »

Depending on the sensor you could possibly eliminate the Trinket. Just go sensor>transistor>motor. However it is no longer "smart" at that point, just on - off.

User avatar
jbc
 
Posts: 159
Joined: Wed Aug 14, 2013 7:18 pm

Re: Trinket and DC motor

Post by jbc »

Im looking for a smart version but thanks for the input Zener.

Bill-
I think I'll try your approach.
If get one of each;
Trinket.jpg
Trinket.jpg (25.18 KiB) Viewed 697 times
Plus a 5V trinket + a 3AA battery pack https://www.adafruit.com/products/727
to run this smart sensor motor controller.

Do the parts look right?

jbc

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: Trinket and DC motor

Post by adafruit_support_bill »

Yes. That looks right.

User avatar
jbc
 
Posts: 159
Joined: Wed Aug 14, 2013 7:18 pm

Re: Trinket and DC motor

Post by jbc »

Bill can you give me a link to the 270 Resistor please? I can't find it on your site.

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: Trinket and DC motor

Post by adafruit_support_bill »

We don't have any through-hole resistors in the store at the moment. You can try Radio Shack or Mouser.
If you plan on more projects in the future, there are some nice reasonably priced assortments out there too.:
http://www.amazon.com/s/ref=nb_sb_noss_ ... =resistors

User avatar
jbc
 
Posts: 159
Joined: Wed Aug 14, 2013 7:18 pm

Re: Trinket and DC motor

Post by jbc »

Thanks Bill.
I found these- E-Projects - 270 Ohm Resistors - 1/4 Watt - 5% - 270R
I want to check the details before I hit the 'buy' button and I dont know what the '1/4 Watt-5%' means.
http://www.amazon.com/E-Projects-Resist ... m+resistor

jbc

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: Trinket and DC motor

Post by adafruit_support_bill »

1/4 watt means it can dissipate 1/4 watt (e.g. 200mA @5v) which is plenty for this application.
5% is the tolerance - i.e. 270 ohms +/- 5%. Also more than precise enough for this application.

User avatar
jbc
 
Posts: 159
Joined: Wed Aug 14, 2013 7:18 pm

Re: Trinket and DC motor

Post by jbc »

Thanks for the speedy response.
You have helped take the edge off of trying out new things.
I'm sure I'll be back on this thread over the weekend once I start soldering.
Thanks.
jbc

User avatar
jbc
 
Posts: 159
Joined: Wed Aug 14, 2013 7:18 pm

Re: Trinket and DC motor

Post by jbc »

Bill,
I want a sensor when it hits a resistance value that is written in the code turn on a motor for x amount of time.

Does the wiring look right?
(The diode is between the motor terminals)
Sensor.jpg
Sensor.jpg (453.2 KiB) Viewed 631 times

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: Trinket and DC motor

Post by adafruit_support_bill »

It looks like you are connecting both the sensor and the transistor base to pin #0. That won't work. They pin can't be both an input and an output at the same time.

To read a resistive sensor, you need to use an analog pin. Pin #2 can be used as an analog input: https://learn.adafruit.com/introducing-trinket/pinouts

User avatar
jbc
 
Posts: 159
Joined: Wed Aug 14, 2013 7:18 pm

Re: Trinket and DC motor

Post by jbc »

OK.

My diagram in all it's glory (ignore my spelling of 'resistor' and 'transistor.' This pic seem's to be 's' deficient).
If this looks right I'll start soldering away this weekend.

If wired correctly I hope to get a motor to turn for 10 seconds (or whatever I code for) when the resistive sensor value is reached, powered by 3 AAA batteries.

5V Trinket running DC motor when sensor is triggered.jpg
5V Trinket running DC motor when sensor is triggered.jpg (416.91 KiB) Viewed 614 times

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”