Moving the timer device described in a previous post from the PICAXE 20M to the 08M in order to save space has brought with it the problem that one has a limited number of out pins at one’s disposal. In particular, when the user selects the timer function of the device, i.e. teeth or eggs, we want to indicate the selected function via two LEDs. In the 20M version of the circuit we could wastefully use two output pins (out4 and out5) for this purpose but with the 08M a little thought is required. One option would be to use a NOT gate to inverse the output of the selected function thus saving a pin. However given the space limits, using a NOT chip for just one NOT gate takes up too much room. The images below give you a good impression of how tight the space is inside the selected enclosure.
As can be seen in the image above, the enclosure is too small for the PICAXE-08 Proto Board with 3 AA cells which provides the required 4.5v to power the circuit. To cut down on space, we have used a 9v battery but this requires a 5v voltage regulator to be built onto the PICAXE-08 Proto Board.
Given the now limited space on the Proto Board, adding a 14 pin NOT chip for one gate is pretty wasteful. In comparison a single NPN transistor has just three pins for the base, the collector and the emitter. As a side note, the transistor is a truly incredible device and it is viewed as one of the most important inventions of the 20th century which is why it’s inventors (Shockley, Bardeen and Brattain) were awarded the Nobel Prize for Physics in 1956. I recommend taking a look at it in more detail. Below is an image of a CD4069 six gate NOT chip compared to a C547B NPN transistor which we will be using in this post to create a single NOT gate.
The construction of a NOT gate from the NPN transistor is pretty straight forward as one can see in the circuit diagram below. The input +5v is connected to a switch and then a 10k resistor to the base, the collector is also connected to +5v via a 330 ohm resistor. The output of the gate is connected to the collector and will be high when the switch is open and low when the switch is closed. Using this circuit saves a substantial amount of space on our Proto Board – as well as being an excellent way to introduce the transistor to my son.
As always, the code for the circuit is listed below – simply copy and import it into Circuit Simulator to give it a try.