Attiny2313 Based Electronic Hourglass
by artworker in Circuits > Electronics
3152 Views, 35 Favorites, 0 Comments
Attiny2313 Based Electronic Hourglass
I got an arduino a long time back to play around. Made some basic projects to start with. But never quite liked using it. No, arduino is awesomely good. But the some pain points were:
It needed 5V to power
It's pin outs are a little complicated to work with considering we use jumper wired
It is heart breaking if we damage it considering the cost
So I was looking for some easier alternatives. I got hold of an ATTINY2313 chip. Google gave me some pointers how to use and program it. Pros of using this chip was
It is cheap
It has lots of pin outs (18 to be precise)
Can use it on any board we like
Pin out can be soldered
Best of all, It can be powered through a 3V supply
So I started to play around with this chip. I used the Arduino as an ISP and made a blinking LED. the I made a dimmer LED. Then I thought, why not make an hour glass with this chip. That will be fun.
Hourglass the Thought
So i thought about it. Made some sketches on how it will be. I finalized on a board with 20 LEDs, 10 for the upper half and 10 for the lower half.
Then I thought about the pins of ATTINY2313 that will be used. I finalized on 12 pins. 10 pins will be parallel for upper and lower part of the LEDs and 2 pins will be like the control pins. But after making the so called truth table and thinking about it I discarded the 2 pins as they looked redundant and I managed the thingy by directly connecting them to the VCC and GND rails. So I am ready with the circuit.
Circuit explained:
When a pin is high state (1) the left led (upper part) lights up.
When a pin is low state (0) the left led (lower part) lights up.
Programming
Google gave me some idea how to program the ATTINY2313. We just have to set the arduino as an ISP, make some connections and upload the program to the 2313. My program was not big at all considering the hardware designed and the operation marked in the truth table.
Hardware
I made the hardware on an experimental board that was lying around. Soldered all the LEDs, soldered the microcontroller base as I did not want to overheat and damage the chip considering my soldering skills. Oh yes! This time I also added a switch contrary to my previous electronic experiments. Soldered all the wires as required and we are done.
The Program
It is a pretty simple program. No loops and all. Just a expansion of the basic blink program
// the setup function runs once when you press reset or power the board
void setup() {
pinMode(16, OUTPUT);
pinMode(15, OUTPUT);
pinMode(14, OUTPUT);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(16, HIGH);
digitalWrite(15, HIGH);
digitalWrite(14, HIGH);
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
delay(2000);
digitalWrite(16, LOW);
delay(2000);
digitalWrite(15, LOW);
delay(2000);
digitalWrite(14, LOW);
delay(2000);
digitalWrite(13, LOW);
delay(2000);
digitalWrite(12, LOW);
delay(2000);
digitalWrite(11, LOW);
delay(2000);
digitalWrite(10, LOW);
delay(2000);
digitalWrite(9, LOW);
delay(2000);
digitalWrite(8, LOW);
delay(2000);
digitalWrite(7, LOW);
delay(2000);
}
Finally
After all the soldering is done I attached the controller chip in its socket, attached 2 batteries and switched it on.
By God's grace everything worked at the first go!