I used the Tinkercad hole feature to make the Traffic Light shell look like an x-ray in Figure 2. This allows you to see the red X piece I inserted into the original design. I’ll change the shell back into a solid object before I produce the .STL file and combine it with the X so it all prints as one solid piece.
Electronics
Once I had the 3D printed parts the way I wanted them, I decided to use Great Cow Basic and a CHIPINO mini module to run twelve LEDs to form a full working traffic light. This could be used as a desk decoration or a functional toy for kids. The CHIPINO mini fit in the base and I thought I could fit some batteries but I later found out I was wrong. It was just too tight.
I already had some sample code for a three LED Traffic Light in my book Programming PICs in BASIC so I just modified it for Great Cow Basic and 12 LEDs.
The program is simple as it just rotates through three I/O for Red, Yellow and Green on one direction and a second set of three I/O for the other direction Red, Yellow and Green. The LEDs on opposite sides are connected together, Green-to-Green, Red-to-Red and Yellow-to-Yellow.
I printed the traffic light out in white plastic first and wired up a single set of three LEDs just to make sure everything fit. I used hot glue to hold the LEDs in place. Everything worked great so I printed the final version in black plastic but yellow would probably have made more sense. I didn’t have any yellow so black it was.
The final design is shown in Figure 5. It has independently controlled LEDs and is easy to see with the black background. A could of small screws held the shaft unit to the base. I was able to position the programming header into the slot originally designed for the USB connector.
'A program to create a traffic light
'on Digital pins 8 thru 13 on CHIPINO
'Chip model
#chip 16F886, 4
#include <chipino.h> 'Defines CHIPINO setup
#define Red D13 ‘RB5
#define Yellow D12 ‘RB4
#define Green D11 ‘RB3
#define Red2 D10 ‘RB2
#define Yellow2 D9 ‘RB1
#define Green2 D8 ‘RB0
'Main routine
Start:
'Red Light
set Red on
set Red2 off
set Yellow off
set Yellow2 off
set Green off
set Green2 on
wait 4 s
'Yellow2 Light
set Red on
set Red2 off
set Yellow off
set Yellow2 on
set Green off
set Green2 off
wait 1 s
'Green Light
set Red Off
set Red2 on
set Yellow off
set Yellow2 off
set Green on
set Green2 off
wait 4 s
'Yellow2 Light
set Red off
set Red2 On
set Yellow On
set Yellow2 off
set Green off
set Green2 off
wait 1 s
'Jump back to the start of the program
goto Start