Introduction: Personalized Message Displaying Trinkets
Around last month, we were welcoming our new freshmen to the department. My friend came up with an idea that we should have some kind of gifts for them, and this is my take for that. It took me a day to experiment on how to build the first one, then several hours to build the rest 4.
The trinket is ATTINY414-controlled. The message is stored on the MCU and then displayed one letter at a time on the common anode 7 segments display. You could have a very long message since my 10 letters word used up only 400 bytes of program space on the 4k device. The 7 segments display cathode pins are connected to the MCU through 1k resistors.
I tried to use as many parts I already have on hand as possible and it turns out we only have to buy battery holders and batteries. The trinket is pretty cheap to build too, coming at just over 2$ each excluding the battery.
This piece is ideal for decoration or for hanging on your bag.
Note: This is my first Instructable and I took waaay fewer pictures than I should. I will make up for those by drawing some sketches for those steps I have no pictures. Also sorry for potentially confusing writing.
Note 2: You can use any microcontroller for this project, butthe placement in this Instructable is for ATTINY414 and other pin-compatible devices.
(The list is for 1 piece)
- 1x Breakout board for SOP28/TSSOP28 chip
- 1x ATTINY414 (you can use other microcontrollers and adapt it yourself)
- 7x 1k resistors (THT, 1/4 or 1/8 W)
- 1x 100nF capacitor (THT or SMD)
- 1x 0.56in common anode 7 segment display
- 1x Slide switch
- 1x Coin cell battery holder (I used CR2032 here.)
- Some AWG30 wires and resistor legs (for jumping in tight areas)
- Sticker or Double-sided tape (for covering the area to prevent shorting)
- 1mm shrink tube
- 1x keychain
- Soldering iron and smoke extractor
- Helping hands or PCB holder
- Small diameter solder (I used 0.025in.)
- RMA Flux
- Alcohol wipes or Isopropyl Alcohol + Flat brush
- Tissue paper
- Masking tape
- Microcontroller programmer (based on your MCU)
Step 1: General Design
These sketches are the rough layout of how things are placed on the breakout board in my design.
Note: The breakout board I use has a pin number on each hole based on the common IC leg numbering on each side. When I address these holes, I will use Txx for the top side (where the MCU is placed) and Bxx for the bottom side. If you are confused about where to solder things, refer to these pictures.
Step 2: Test Your Components
Before you start, make sure that your parts are in working condition, especially the microcontroller and the display. Since the parts will be crammed in the small spaces, finishing it and then realized that your display doesn't work is the last thing you want, so test them first!
Step 3: Program the Microcontroller
The program for the microcontroller is pretty simple and consists of the following steps:
- Set the pins low for the first letter.
- Delay a bit
- Set the pins all high to blank the display (optional)
- Delay a bit
- Set the pins low for the second letter.
- Rinse and Repeat
I've attached the code I used. You can compile it with an XC8 compiler on MPLAB X. However, since I used PA0 for segment A, you will have to disable UPDI via fuse bit for it to work (explanation below).
Selecting the right ports
Now you have to select which ports of the microcontroller to use. Normally for the microcontroller with 14 pins, there will be one 8-bit port and one 4-bit port. Since the 7-segment display has 8 cathode pins (including the decimal point), using the 8-bit port is the most convenient because you can use direct port access to set the port value in a single command.
Consideration 1: Cross-traces
However, the choice might vary due to your microcontroller pinout and wire routing between your MCU and the display. To make the work easiest, you want the least amount of cross-traces.
For example, on ATTINY414 the 8-bit port is PORTA. If you assigned PA0 to segment A, PA1 to segment B and so on, the amount of cross-trace is 1 (segment F and G) which is acceptable for me.
Protip: One side of the board can safely house five 1/4 w resistor.
Consideration 2: Pins' alternate functions
In some cases, if the pins on the port you want to use have alternate functions such as programming pins, these pins will not work as GPIO pins, therefore you might have to avoid them or disable programming altogether, the choice is yours.
For example, on ATTINY414 the UPDI programming pin is on the A0 pin on PORTA. If you use this port as the output, it will not work because the port will be used as UPDI instead of GPIO. You have 3 options here with their pros/cons:
- Disable UPDI via fuse bits: You will not be able to program the device again unless you use 12v to re-enable the UPDI function (unfortunately I did this but you don't have to).
- Use only PA7-PA1: You will not be able to use a decimal point here unless you also use PORTB to help, but you will still have programming available (best option).
- Use PORTB to help: Longer code but also works if the pinout is too messy otherwise.
Protip: Try to select the microcontroller with less amount of programming pins, ATTINY414 uses UPDI which only uses 1 pin to communicate, thus you have more GPIO pins available.
Programming the device
If you have a programming socket for the SMD device you might want to program it before soldering the MCU to the breakout board. But if you don't, soldering first might help you with the programming. The mileage may vary. In my case, I connect the PICKIT4 to one breakout board then use my finger to push the MCU against the board. It works but not very good (the programming socket is now on my wishlist).
Step 4: Solder the Microcontroller
There's nothing fancy at this step. You have to solder the microcontroller to the breakout board. There's plenty of tutorials on Youtube on how to solder the SMD parts. To summarize, the essentials are:
- Clean soldering iron tip
- The right amount of solder
- The right temperature
- A lot of flux
- A lot of patience and practice
Important: Make sure to solder the MCU's pin 1 to pin 1 of the breakout board!
Now that the MCU is soldered to the board we can continue to the next step.
Step 5: Solder the Capacitor
There's a rule of thumb in electronics that when you have an IC in your circuit, add one 100nF capacitor near its power pins, and that's no exception here. This capacitor is called a decoupling capacitor and it will make your circuit more stable. 100nF is a general value that works with most circuits.
You have to solder the capacitor as close as possible across the Vcc and GND pins of the MCU. There's not much space here so I just cut its legs to size and solder it directly to the MCU's legs.
Step 6: Flux Cleaning 1
While flux is essentials for soldering. Leaving it on the board after soldering is not good for you because it can corrode the board. Residue flux could be dissolved using Isopropyl Alcohol. However, you also have to wipe the flux off the board before the alcohol evaporates away or else the sticky flux will now cover the whole board.
This is the technique I use that works pretty well: place the board sideways on a tissue paper, then soaked a flat painting brush in alcohol and quickly "paint" the alcohol on the board downwards to the tissue paper. You will see yellow flux appearing on the tissue paper. To be sure that most of the flux is removed, check if your board is not sticky and pools of flux around solder joints are mostly disappeared. See a picture above for more details.
Reason for this cleaning: To clean the microcontroller. The part will be much harder to reach later.
Step 7: Solder the 7-segment Display
Now we will break the rules about soldering the lowest profile devices first and start from the 7-segment display. This way we could just solder the resistors to the 7-segment display's legs.
Since we now have very limited free holes left on the board, we will cut away the bottom common anode pin of the display to make way for the negative pin of the battery holder. Then solder normally. Just bend the display's legs outward a bit, hold it in place (masking tape might be helpful here) and solder it on the top side of the board.
Step 8: Solder the Bottom-side Resistors
Next step would be to solder the resistors on the bottom side of the board. Before we begin, place double-sided tape or sticker over the TSSOP pads we didn't use to prevent shorting.
Now that the pads are covered, get your resistors out and start bending their legs. They will connect between the MCU legs (LEFT side of the board) and the display legs (RIGHT side of the board). Make sure they don't touch each other and have sufficient spaces between them.
Protip: Your breakout board might come with some holes drilled on the board. These are convenient spots to attach the keychain. Make sure one of these holes aren't covered by resistors' legs.
Step 9: Solder the Top-side Resistors
If you can't fit every resistor on the bottom side of the board, you might have to put some on the top side. Since the microcontroller is also on this side you will have to shrink-tubed your resistor legs to prevent them from touching the microcontroller. The rest of the procedures stay the same as the last step.
Step 10: Solder the Switch
The next part to solder is the slide switch to turns the power on and off. I use a 1P2T slide switch here.
Again due to limited holes left, cut one side pin of the switch off.
Then solder the remaining side pin of the switch. Leave the center pin unsoldered.
Step 11: Solder the Wires and Jumpers
Based on your design, you might have more or less amount of wires to solder. In my design, there're 2 wires (power wires for the MCU) and 2 jumpers (power for the display and extra bridging for the MCU).
Just solder them correctly and you're good to go.
Step 12: Flux Cleaning 2
Reason for this cleaning: We will no longer have access to the bottom side after we soldered the battery holder, therefore we have to clean now.
Step 13: Solder the Battery Holder + Any Additional Jumpers
This is the last and trickiest part to solder. We don't have enough dedicated holes left for the battery holder so we will solder it like this: The positive terminal shared the hole with the switch's leg we left unsoldered (step 10) and the negative terminal goes in the hole we have left by cutting the display leg off (step 7).
Then, if you have any additional jumpers to solder, solder them now. For my design, I have one jumper left because it has to connect to the negative pin of the battery holder.
See the picture for more details.
Step 14: Flux Cleaning 3
Reason for this cleaning: The final cleanup.
Step 15: Testing + Final Touchup
Before we put the battery in, make sure that no legs touch each other, snip any excess leads, check your soldering. After those are done, you can put a battery in, turn it on and it should work properly.
If not, check all of your solderings again and maybe check if your microcontroller program is correct.
Step 16: Final Product
Congrats! You've made your own personalized trinkets! Be sure to share it with me here and enjoy!
Participated in the
First Time Author Contest