Counters are used everywhere, not only in computers. In the 70s and 80s, lots of chips were developed which could count pulses. One of them was the CD4024, a seven-stage binary counter. Unfortunately, I could not find LED modules with 7 LEDs, so I took the one with only 6, and it only can count up to 63.
This is all you need. After you inserted the wires, you can place the LED module in a way that the GND pin matches pin-7 of the chip as shown in the top picture.
The top right corner goes to GND of the power supply, the top left to +Vcc=3-15 volts.
On each press of the button the counter will increment by one, and the result will be displayed on the LEDs. If you remove the 1 MOhm resistor it will not work. If you remove the capacitor, pressing the button will produce bouncing pulses. If you remove both the counter will count by itself at random.
Students should take down notes how long it takes until LED4 is lit, until LED5 is lit, until LED6 is lit and until all are off again.
Using a small microcontroller ATtiny44Replacing the MSI chip by a microncontroller, the project nearly became "wireless". The ATtiny44 comes in a DIL-14 case, and - big surprise - pin-14 is not Vcc as on most DIL-14 chips, but is GND instead.
That makes it extremly easy to place the LED module next to pins-8 to 14. Also, handling the pushbutton can be supported by software: the resistor becomes redundant by setting the input to INPUT_PULLUP, and the capacitor is no longer needed as a short delay helps suppressing bouncing pulses.
The only wires you really need are the ones to connect the pushbutton. The project can be powered by a small CR2032 battery.
Programming can be done using any ARDUINO and some wires as shown by Maximous:
https://www.instructables.com/Program-an-ATtiny44458485-with-Arduino/
/*
binary counter with ATtiny44
*/
const byte t1 = 6;
const byte d0 = 5;
const byte d1 = 4;
const byte d2 = 3;
const byte d3 = 2;
const byte d4 = 1;
const byte d5 = 0;
void setup() {
begin();
}
byte bit0, bit1, bit2, bit3, bit4, bit5;
void loop() {
if (S1()) {
if (bit0 == 0) bit0 = 1; else {
bit0 = 0;
if (bit1 == 0) bit1 = 1; else {
bit1 = 0;
if (bit2 == 0) bit2 = 1; else {
bit2 = 0;
if (bit3 == 0) bit3 = 1; else {
bit3 = 0;
if (bit4 == 0) bit4 = 1; else {
bit4 = 0;
if (bit5 == 0) bit5 = 1; else
bit5 = 0;
}
}
}
}
}
while (S1());
delay(100);
}
digitalWrite(d0, bit0);
digitalWrite(d1, bit1);
digitalWrite(d2, bit2);
digitalWrite(d3, bit3);
digitalWrite(d4, bit4);
digitalWrite(d5, bit5);
}
void begin() {
pinMode(t1, INPUT_PULLUP);
pinMode(d0, OUTPUT);
pinMode(d1, OUTPUT);
pinMode(d2, OUTPUT);
pinMode(d3, OUTPUT);
pinMode(d4, OUTPUT);
pinMode(d5, OUTPUT);
}
boolean S1() {
if (digitalRead(t1) == LOW) return true;
else return false;
}
Comments