Because we can. I had a 7-segment display left over from the #Talk Ranking Machine, and this really begged to be done. Yes, it's useless, silly, and potentially even dangerous if someone left it in a public place. But it was quite fun to do too.
Both the display and the battery holder are soldered directly to the Pro Mini -- the pinout just happens to match. There is no off switch, you just have to remove the battery. The code looks like this:
constint GND_PINS[] = {8, 12, 13, A2};
constint VCC_PINS[] = {A1, 11, 6, 4, 3, A0, 7, 5};
constunsignedchar DIGITS[] = {
0b00111111,
0b00000110,
0b01011011,
0b01001111,
0b01100110,
0b01101101,
0b01111101,
0b00000111,
0b01111111,
0b01101111,
};
constint BEEP_PIN = 2;
voidshow7seg(int number){
unsignedchar digit;
div_t result;
for (int d = 0; d < 4; ++d) {
result = div(number, 10);
digit = DIGITS[result.rem % 10];
number = result.quot;
for (int s = 0; s < 8; ++s) {
digitalWrite(VCC_PINS[s], digit & (1 << s));
}
pinMode(GND_PINS[d], OUTPUT);
digitalWrite(GND_PINS[d], LOW);
delay(2);
pinMode(GND_PINS[d], INPUT);
}
}
voidsetup(){
for (int s = 0; s < 8; ++s) {
pinMode(VCC_PINS[s], OUTPUT);
}
for (int d = 0; d < 4; ++d) {
pinMode(GND_PINS[d], INPUT);
}
pinMode(9, OUTPUT);
digitalWrite(9, LOW);
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);
}
voidloop(){
staticlongint last = 0;
staticint count = 2400;
longint now = millis();
if (now - last > 500) {
digitalWrite(10, LOW);
}
if (now - last > 1000) {
count -= 1;
if (count % 100 == 99) {
count -= 40;
}
last = now;
tone(BEEP_PIN, 1200, 25);
digitalWrite(10, HIGH);
}
show7seg(count);
}
And that's pretty much it. I might actually make it a game, by adding several wires that you have to cut, that would either stop the counter or make it go faster or something...
Excuse me? What are you babbling about? What the heck is a "muslim extremist activist" and why is he at your school? And what does it have to do with any clock? Look at the date of this project and recheck your jumping to conclusions, please.
I used blue LEDs, because they take higher voltage, and I was uncomfortable connecting them without any resistors, so I wanted to limit the damage, if any.
This is a 3V button battery, it has very weak current and the voltage drops immediately when you try to draw any sensible ampers. So that's much safer than, say, a 25C LiPo :)
XDXD i clicked on the bomb tag and was disappointed by the project amount. we need more homeade bombs