I am using an Arduino Uno in a project and would like to scale down size and costs. I am a newbie, but see that I am only using a total of 5 pins; #2 for a PIR sensor (which returns data), #3 for data from several LED strips(which use PWM), #4 for clock from same strips and Vin+Grnd pins for power. Can I scale down from an Uno to a Trinket without altering my existing and well functioning program much?
Thanks
Will a Trinket sub well for my Uno?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- michaelmeissner
- Posts: 1822
- Joined: Wed Aug 29, 2012 12:40 am
Re: Will a Trinket sub well for my Uno?
In theory you should be able to use a Trinket. You might also be able to use a Gemma (same cost, but different layout and fewer pins). The ground/vin pins don't count towards the total. On the Trinket you would use pin PB2 for the PIR circuit (which provides analog input), PB0/PB1 both have PWM so you could use either for the LEDs, and the other for the clock (given the internal LED is on PB1, that might be an easy choice to use for the LED strip). You can also use PB4 for another PWM pin and PB3 for another analog pin, but those are used by the USB controller, and you would need to remove the stuff from those pins when programming the chip.
Note, that the Trinket does not have builtin serial support, so you wouldn't be able to do Serial.print for debugging. There are ways to do SoftwareSerial or such for debugging, but I tend to do the Serial debugging on the Uno or Teensy 3.0 processors, and then just use LED debugging on the Trinket/Gemma.
Note, that the Trinket does not have builtin serial support, so you wouldn't be able to do Serial.print for debugging. There are ways to do SoftwareSerial or such for debugging, but I tend to do the Serial debugging on the Uno or Teensy 3.0 processors, and then just use LED debugging on the Trinket/Gemma.
- annie mouse
- Posts: 39
- Joined: Sun Dec 30, 2012 9:58 am
Re: Will a Trinket sub well for my Uno?
Helpful info-thanks much Michael!
- annie mouse
- Posts: 39
- Joined: Sun Dec 30, 2012 9:58 am
Re: Will a Trinket sub well for my Uno?
"There are ways to do SoftwareSerial or such for debugging, but I tend to do the Serial debugging on the Uno or Teensy 3.0 processors, and then just use LED debugging on the Trinket/Gemma."
Michael,
Can you give me some more background on how to do this type of debugging?
Thanks,
Michael,
Can you give me some more background on how to do this type of debugging?
Thanks,
- michaelmeissner
- Posts: 1822
- Joined: Wed Aug 29, 2012 12:40 am
Re: Will a Trinket sub well for my Uno?
Well, there are several ways to do debugging. Most of them in the Arduino/Trinket case, if you get to a certain point change some state that you watch to see if it got there.
The LED approach, just turns the LED on/off when you get to specific points in the program. If you need something more, you could blink the LED at particular rates. You could also use analogWrite on the LED and change the PWM light to indicate something.
Going slightly more complex, if you are using i2c, you could put a MCP23017 on your i2c bus, and then you can turn on different lights, depending on the conditions. You could either use a tri-color led for 3 different states. Or you can use multiple LEDs like this one to give you multiple lights: http://www.ebay.com/itm/281193064323?ss ... 1439.l2649
Or put a 7 segment display with backpack, and then you can display 4 separate digits (plus a few random dots).
As I said, one approach is to use serial debugging on the Uno, before going to the Trinket, and use serial.println's to indicate where you are. You would put:
Now, it would be really nice to have gdb debug support like I have under Linux. Debugging an Uno, Trinket, etc. reminds me when I started programming, in that I submitted job decks on punched cards, and then picked up the printout later (except when I first started, the turn around at some places was overnight, so you only got one shot a day, to make changes, while with an Arduino you can change the code and reload it).
The LED approach, just turns the LED on/off when you get to specific points in the program. If you need something more, you could blink the LED at particular rates. You could also use analogWrite on the LED and change the PWM light to indicate something.
Going slightly more complex, if you are using i2c, you could put a MCP23017 on your i2c bus, and then you can turn on different lights, depending on the conditions. You could either use a tri-color led for 3 different states. Or you can use multiple LEDs like this one to give you multiple lights: http://www.ebay.com/itm/281193064323?ss ... 1439.l2649
Or put a 7 segment display with backpack, and then you can display 4 separate digits (plus a few random dots).
As I said, one approach is to use serial debugging on the Uno, before going to the Trinket, and use serial.println's to indicate where you are. You would put:
Code: Select all
void setup (void)
{
#if !defined(__AVR_ATtiny85__)
serial.begin (9600);
#endif
}
void loop (void)
{
if (condition ()) {
#if !defined(__AVR_ATtiny85__)
serial.println ("Here I am");
#endif
}
}
Please be positive and constructive with your questions and comments.