Sheepdog Software HOME

Adafruit Trinket

(filename: trink1getStarted.htm)

((q-alt text for image))

_____________________

I'm in love... again. (1/19)

If you want to give me a super duper $5000 ultra gaming machine, I won't say no.

Or a $2500 sturdy workhorse, which does half what the big one would.

Or even a $1250 "basic" computer, I still would be grateful.

But by that logic, how much should $6.95 buy you?

$6.95 will buy you a full blown von Neumann computer. 8 or 16Mhz clock. 8k of flash ram, 512 bytes of SRAM, 512 bytes of EEPROM. Easily programmable in a C++- like language.

Of course, 8/ 512/ 512 may not sound like much... but your big ultra gaming machine will have to load programs from backing store. It won't have them resident in mapped non-volatile memory, will it? $5000 is 719x $6.95. Does the big gaming machine run at 5,000 MHz? I don't think so!

Anyway... some people learn to derive a pleasure from doing more with less.


((q-alt text for image))

====================
Here's what you get for your money.....

It is the "Trinket", from Adafruit.

Now... I had a little bad luck. I knew it had been around for a while. I'd played with, and liked, the ATtiny85's it is based on. (Even simpler, but a little more hassle to program... still Arduino compatible, but you can't program across a USB connection... but you get easier access to all GPIO lines. Choices! Choices! (With Trinket, two GPIO lines have to be used carefully.))

Bad timing! Near the end of 2018, I bought two Adafruit Trinkets.

By the time I went to play with one of them, the product description opened with...

Description-

Deprecation Warning: The Trinket bit-bang USB technique
it uses doesn't work as well as it did in 2014, many
modern computers won't work well. So while we still
carry the Trinket so that people can maintain some older
projects, we no longer recommend it. Please check out
the Trinket M0. It has built-in USB, more capabilities,
and is comparable in price!

(https://www.adafruit.com/product/1501 ,accessed 5 Jan 2019, 15:24)

The details of "won't work well" are pretty sketchy, aren't they? I read on the internet that USB 3 ports may be problematic. Okay... many PCs offer some USB 2 ports. Or, you can connect the Trinket through a USB2 hub. If you know or discover any other details about the "won't work well", I'd be grateful if you wrote to me. (Contact details at bottom.)

However...

a) I found the Trinket worked fine for me, at least in preliminary tests, and

b) There is a "new improved" version, the "Adafruit Trinket M0" (M zero, I believe) (It has a different processor, and only costs $2 more. It has the virtues of the first generation Trinket, and more of... everything! (32x the Flash, 64x the RAM, 6x faster processor. Not bad for an extra $2!. It can be used with Arduino IDE or CircuitPython. All 5 GPIO pins are available and are not shared with USB - so you can use them for whatever you like! Can drive NeoPixels or DotStars on any pins, with enough memory to drive 8000+ pixels. DMA-NeoPixel support on one pin so you can drive pixels without having to spend any processor time on it. Native hardware SPI, I2C and Serial available on two pads so you can connect to any I2C or Serial device with true hardware support (no annoying bit-banging). You can have either one SPI device or both I2C and Serial... LOTS to like! (If I didn't already have my "mark 1" (ATtimy85) Trinkets, I would certainly be buying the still-less-than-$10 M0s!))

But what I had/ have is the older ATtiny85 Trinket, and the rest of this is about my experiences getting started with one of those.





((q-alt text for image))

5 Jan 2019, 15:15, I plugged a 5v Trinket into my Windows 10 desktop (Lenovo 90F1006FUS) (My ref: pc2ndEllie, Trinket: ICH08a)

"Stuff" happened. Had a fleeting notification that my Trinket was now ready for use.

Trinket's green LED had come on when power applied. Red LED flashed for about ten seconds, went dark.

(All as it should have been.)

Foolishly, accidentally, I had my Arduino IDE (1.8.5) running, with a sketch for something else loaded, at the time. Happily, at least I had unplugged the Arduino for that project before plugging in the Trinket. No problems arose. (Saved that, closed the IDE. Later, when I restarted, the old project was loaded for me, as usual. I merely did File/ New to start the new, Trinket, project. More on that later.)

I checked "Tools/Port" from the Arduino IDE... didn't see a likely candidate for the Trinket. Later I learned that I shouldn't have. All was well.

READ THE EXCELLENT HELP ADAFRUIT HAS PROVIDED! I'm not going to cover everything that's there here! (But I will sketch my experiences, as reassurance for you, I hope. And I will interject some hints.

------------------
Early on, the new Trinketer is told "If you're using Windows be sure to follow the instructions on the Windows Driver Installation page to install the appropriate drivers for your Trinket."

Given the notification I'd had when I plugged my Trinket into my PC, (a little early in the game), I thought maybe I could skip this, hoping that the driver installation had become automatic since the tutorial was written. Nope.

If for some reason you think you can skip installing the driver, use the Arduino IDE to check what you see with "Tools/ Programmer". Until I installed the driver, I didn't have the "USBtinyISP" option, which is what you use for the Trinket. (Be sure to note what you are using now, so you can go back to it after playing with your Trinket!)

As I was saying: I thought maybe I could skip the driver installing.

Not.

If you are working under Windows, you do need to go through the "install drivers" steps set out in the guide. But they are explained well, take little time, despite all the text to describe what you do... which follows...

Installing Windows Drivers

So here's what I had to do, to install the necessary Windows Drivers. As with much of the rest of this, I am merely re-stating what is in the good guide from Adafruit, with just the odd "editorial" note along the way....

What I did is covered in the Windows Driver Installation page of the Adafruit Trinket guide.

The link took me to a github page headed "Add Trellis M4 Express".. and on it, there was an "Adafruit_drivers_2.3.3.0.exe" entry.

Downloaded that; ran it. (Select file, click "Download" button, upper right... easy to overlook.)

Not wanting more "done to" my PC than I could help, I UN-ticked the "Feather WICED" entry, left Trinket (etc) ticked, and left other two unticked, crossed fingers, and clicked "Install". (This worked.)

*** Nota bene: Along the way, I un-ticked the easily overlooked "Always trust software from Adafruit" in the dialog that followed. (I do trust Adafruit, but I still want to be asked when software installs arise.)

"Stuff" happened, and the driver was installed. My evidence: after the next steps, there was a "USBtinyISP" option on the "Tools/ Programmer" dialog. (The IDE must be shut, re-opened, if it was open while you were installing the drivers. Probably a bad idea, by the way.)

Next steps

I was a little confused by what came next in the guide. It talked about...

(quote)... Before you try to upload code to the Trinket
it must be in the Bootloader Mode. That means its listening
for a sketch or program to be sent to it...(end quote)

It wasn't that I didn't understand what they were saying, I was only puzzled by the context. This appears in the guide, in my view, way ahead of where it ought to be. Don't worry about it for now. I'll explain what it was saying when the right time comes.

Don't Panic! (Mr Mannering)

I hope I've said that early enough? I know that reading a guide like this is depressing, and leads to thoughts along the lines of "This is too much hassle, and too many things to go wrong."

I hope you'll hang in there, persevere. It really isn't too terrible, and once you have things set up... not a huge task... you'll be able to program these inexpensive little delights almost exactly as you program an "ordinary" Arduino.

Okay... there aren't as many I/O lines. No serial monitor. But... $6.95!!! (Trinket M0 had 5 uncommitted GPIO pins, AND serial I/O.)

Onward....

Call me boring, but I intended to try a "Trinket Blink" to see if I'd understood the instructions and done everything that was necessary. My advice: Always make sure you can walk before you try to run.

But first there were a few more "do once" things to deal with...

Earlier, I had disconnected my Trinket almost as soon as I connected it. (I probably shouldn't have connected it so early, but... you know! (It is not a good idea to start the IDE with an Arduino or Arduino-compatible unless you are sure that the right Tools/Board setting are in place, or that you will be making them immediately.))

)

Started my Arduino IDE. I was still on vers 1.8.5, which seemed Just Right. Earlier isn't enough, and too much later may not play nicely. (More on that later.)

Loaded the "01.Basics- Blink" example sketch.

*** NOTA BENE *** Quote from a page in the Adafruit guide: "There is currently a bug in Arduino 1.8.7 which requires you to select a Port before upload but we don't use Ports for Pro Trinket uploads. If you don't have a Serial Port available to select, please use Arduino 1.8.6"

Yeah. Well. Good thing I am "behind the times", then, isn't it? (I am on 1.8.5)

This advice to "use an old version" is unacceptable to me... When the time comes to move to something beyond 1.8.5, I will either abandon the Trinket as an interesting footnote, or hope an answer has come along. I suspect that the Trinket M0 does not suffer from any of these problems.

I had an ATtiny85 Trinket in front of me, and decided to press on....

Setting up the Arduino IDE...

By now, I was at the "Setting up... IDE" page of the guide.

The guide says...

Just follow the steps in the Adafruit Arduino IDE
setup guide to easily add support for Trinket,
Gemma, Pro Trinket & more to the Arduino IDE.

You will need Arduino IDE 1.6 or greater

When you're finished installing the IDE & board
manager add on come back to this page to continue
the Trinket guide.

Well... that's mostly right, although I wouldn't install more than the Trinket support, and here's how I did it...

Off I went, via the link provided, to ...

the Adafruit Arduino IDE setup guide.

I followed the Arduino 1.6.x IDE install page route, the "Super Easy Installation" option, which Just Worked for me.

I already had an IDE ahead of 1.6.3, so no problem there.

As instructed, I invoked, in the IDE, "File/Preferences"

ADDED, following a comma, the following...

https://adafruit.github.io/arduino-board-index/package_adafruit_index.json

... to the list of "Additional Boards Managers URLs" already specified for my Arduino IDE installation. (Your installation may or may not already have some specified URLs.)

Clicked "OK" to close the "Preferences" dialog.

Opened the "Boards Manager" by using the Tools/Board/Board Manager.

As instructed, went for "Contributed" type packages.

Found the entry in the list for "Adafruit AVR Boards by Adafruit. (In the fine print, you can see "Trinket"... hurrah"

... and was stuck for a moment!

To get the button that lets you do the install, you need to click somewhere (not on a button) in the "AVR Boards" box to "select"(?) it. Once you've done that, there's an "Install" button, and a listbox with versions. I went for the most recent... 1.4.13 at the time I did all of this, 5 Jan 2019.

I know. I don't like installing stuff on stuff, either. But you really do need to do this, if you want to play with Trinket. And Adafruit is a reliable source.

Anyway... I clicked "install", and promising things happened. Eventually, it all settled down. The "install" button went away.

If you notice details, you'll see that the header for the box, "Adafruit AVR Boards..." now has "INSTALLED" at the end. Also, if you click in the box again, a "Remove" button will appear where the "install" button was previously.

Encouraging!!

To quote Adafruit again...

Next, quit and reopen the Arduino IDE to
ensure that all of the boards are properly
installed. You should now be able to see the
new boards listed in the Tools->Board menu.
(If you can't even see the "Board" entry on
the sub-menu, go ahead and (against my
previous comment) plug the board in.)

If possible, before plugging in your Trinket, look to see what the Arduino IDE's "Tools/Port" is reporting. Make a note of that, so you can go back to it later.

Once I had Tools/Board open: Hurrah, lots of Adafruit boards now available to me. (So I could skip the rest of the "Arduino 1.6.x IDE" page, the "Manual Installation (super advanced!)" part.)

The invitation "Finally follow the steps below for your platform to finish the installation - basically installing drivers and permissions management... Windows Setup"... didn't seem right... the link merely took me back to the page about Windows drivers which I'd skipped over previously. Turns out I was done at this point.

Now... I was using a 3v3 Trinket, https://www.adafruit.com/product/15001pp

I couldn't find QUITE that in the Tools/Board menu... but I did find "Adafruit Trinket (ATtiny85 @ 8MHz)", and went with that. (NOT the "Pro Trinket", note.) (If you want to run your Trinket at 16MHz, I suspect that is relatively easy... but something for later, and I doubt I will chase that myself.)

While you're here, click on one of the serial ports on offer. (It may not be used, it may not be the Trinket, but Just Do It. Long story!)

Before you do the next step:Look and see, under "Tools/ Programmer", what your IDE's Programmer setting is now. Make a note of that, so you can go back to it later.

ALSO: (And that this is the right choice is explained at...
https://learn.adafruit.com/introducing-trinket/setting-up-with-arduino-ide),
...still in the Tools menu, set the PROGRAMMER to USBtinyISP

If like I, you failed to look to see what the previous Programmer setting was, the best I can do for you is to say that I have not found a reliable answer on the web as to what "the usual" setting is, but that I think it may be "Atmel ICE (AVR)". I hope so! (But don't have time for the relevant tests just now.) Let me know if you find the answer!

(You will need to RE-change these things before you go back to "ordinary" Arduino work.)

Go For It...

If not present from before, load the Blink sketch...

File/ Examples/ 01.Basic/ Blink

Don't worry about changing the "LED_BUILTIN" references. They will probably be okay. (They were for me, anyway. And if they aren't they will do not harm, anyway.)

In the code that loaded for me, it said...

Most Arduinos have an on-board LED you can control.
  On the UNO, MEGA and ZERO it is attached to digital
  pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used...

I knew that the LED of the Trinket wasn't on GPIO 13 (it is on GPIO 1, aka PB1)... but I thought I'd leave the sketch as it stood for now, in that respect. If it wouldn't compile, or the LED didn't blink, I could go back to the code, fix the problem.

So leave the LED_BUILTIN references alone, at least for now. However, in....

  digitalWrite(LED_BUILTIN, HIGH);// turn the LED on (HIGH is the voltage level)
  delay(1000);                    // wait for a second
  digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
  delay(1000);                    // wait for a second

... change the two "1000"s to 40 and 120. (If you don't make this change, the blink due to your program, and the blink when the Trinket is in bootloader mode are hard to differentiate.)

The Blink example blinks the red LED. The green LED only says "the PCB has power".

Not as part of your standard routine for the future, but on this occasion: do a Compile before you attempt an upload... just to be sure there are no problems in the sketch. Tweak the code until compiles without protest.

And Now for the Main Event!...

Your Windows drivers are in place. The IDE has been tweaked. You've set, in the IDE, via entries on the Tools menu item, the board type and programmer. You've loaded a simple program (aka "Sketch") into the IDE.

Upload it! Watch it in action!

But first... read thorough the following...

Giving the ATtiny even the semblance of a bootloader was a marvelous achievement.

It has a tiny "flaw" that merely brings you a taste of something that was normal in early Arduino days.

When you are ready to upload a program, just before you click on the "Upload" icon, press the tiny push button on the Trinket... and wait a moment. The red LED should start flashing... about 1 second on, one second off. Click the "Upload" icon as soon as that has started.

The LED will flash for up to 10 seconds, indicating that the Trinket is "looking for" "stuff" being sent to it, via the USB cable, for storing as a program.

If you are working on a large program and the compile step takes a long time you might want to delay pressing the button. If the red LED stops flashing before the upload has succeeded, you will probably have to start the upload process again. Fear not- it isn't hard to get the process right.

By the way- each time you press the tiny button on the Trinket to start the red LED flashing, you will get the Windows "Dum, deedee, dum" to say that a USB device has been attached. This is normal. Don't let that worry you.

Well... there you have it!

Have fun with your Trinket. Amazing for the price!

I hope this guide to getting started was a help to you.



A few words from the sponsors...

Please get in touch if you discover flaws in this page. Ways you are using the Trinket would be of interest, too. Please mention the page's URL. (trink1getStarted.htm)

If you found this of interest, please mention in fora, give it a Facebook "like", or whatever. I've almost given up writing these pages, because it seems they are seldom read, and of course not every reader will use them... so... is there any point? If you want more of this stuff, help!?



   Search this site                 powered by FreeFind
 
Site Map    What's New    Search


Click here to visit my main homepage where you can explore other areas, such as education, programming, investing.




Ad from page's editor: Yes.. I do enjoy compiling these things for you. I hope they are helpful. However... this doesn't pay my bills!!! Sheepdog Software (tm) is supposed to help do that, so if you found this stuff useful, (and you run a Windows or MS-DOS PC) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

How to email or write this page's editor, Tom Boyd


Valid HTML 4.01 Transitional Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. Mostly passes.


Why does this page cause a script to run? Because of the Google panels, and the code for the search button. Also, I have my web-traffic monitored for me by eXTReMe tracker. They offer a free tracker. If you want to try one, check out their site. Why do I mention the script? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....