Electrons: The Adafruit Trinket first experiments

So my journey starts with a trinket

I’m going straight into the deep end here - no maths, not circuit theory, just a relatively cheap little board with a usb socket, some holes to connect things and some LEDs. The idea is that you program the on board micro controller to do things with the some of its pins, either use them to turn thing on and off - or to listen to things connected to them, and make decisions based on that.

The little board cost quite a substantial £8.70 - more than my budget for each of these experiments - but I really wanted to get right in there and start experimenting.

It comes with some header pins to make connections easier - but first of all I need to plug it in..

The board has two LEDs built in, a green one and a red one. When connected to USB computer, the green is supposed to light, and the red one pulse. I plug the board into my mac using a mini-usb cable I had and don’t get the pulse, just a dim, bored pathetic little light:

After a sleep and a while worrying through the Adafruit training section I have an epiphany. It says that the led should pulse when connected to a usb host - not necessarily just usb power. The lead I was using was suspiciously thin, which might mean it was only a power lead.

I’ve spent hours failing to connect an android phone to a mac for similar reasons.

So I swap out the lead for a decent mini usb, plug it in and the pulse starts as shown in the picture at the top of the post. Result!

I’m using a mac and that makes programming the chip slightly easier - it doesn’t need any drivers.. So here is what I did next:

Downloaded and installed the software to program the Trinket (Adafruit Arduino IDE (OSX) here). From now on I’ll call this the ‘IDE'. I had to tell my mac to allow the software to run - as it evilly has not been blessed by Apple.

From the Tools Dropdown of the IDE, in the Board section, set the board to Adafruit Trinket 8mhz. Then in the Programmer section select USBTinyISP

Then you paste the following Blink code* (like Hello World but with lights!) into the IDE.

Now we send this program to the Trinket. But you can only do that if the red light is pulsing and by now its stopped. But on the Trinket there is a small reset switch - so press that - and quickly click on the right pointing arrow on the IDE. After a bit of stuttering of the lights on the Trinket it all calms down and the red light begins to flash.

Bingo.

If this didn’t work then the Adafruit site explains some things to check - also how to set up the IDE in windows as well. Also if you have wired up things wrong you may hear a hissing or a sizzling. There may even be smoke! Probably best to turn thinks off if thats happened with yours.

On a roll now but I wanted to program something! So in the code above I messed about with the delay lines by knocking a zero from the 1000 delay. Once done - you can simply press the trinket reset button and then the upload button on the IDE to experiment with your new code. Altering the delay just made the red led flash quicker.

Matthew Norman...

... who lives in the UK, who is not an actor, not a clock manufacturer, did not write a rough guide to cuba and also has never written for the Telegraph. I have written books on coldfusion and web databases.