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.

Short On Enclosure Space

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.

Using a 9v Battery to Save Space

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.

Saving Space By Using a Single Transistor

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.

NOT Gate Using a Single NPN Transistor

As always, the code for the circuit is listed below – simply copy and import it into Circuit Simulator to give it a try.

$ 1 5.0E-6 10.20027730826997 50 5.0 50
t 624 432 688 432 0 1 -1.7015314360087241 0.09853955010330427 100.0
r 544 432 624 432 0 10000.0
s 480 432 544 432 0 1 false
R 480 432 432 432 0 0 40.0 5.0 0.0 0.0 0.5
w 688 320 496 320 0
w 480 320 480 432 0
w 480 320 496 320 0
g 688 480 688 512 0
r 688 320 688 416 0 330.0
w 688 416 768 416 0
162 768 416 768 480 1 2.1024259 1.0 0.0 0.0
w 688 448 688 480 0
w 688 480 768 480 0