We'll use these two switches to blink an LED a programmable number of times. The LEDs we'll use will be the blinkenlights that The Real Elliot made famous. Switches 1 and 2 will be treated as two binary digits, so the combination can represent the numbers 0, 1, 2, and 3. Our program will read the two switches and blink the LED the appropriate number of times, but only if the switch settings have changed. The switches are debounced for 500 milliseconds (not optimized). The debounce algorithm is pretty simple. The switches are read and the reading is noted. If it is different from the oldBut value (the last saved value), then the program is delayed for 500 milliseconds and the switches are read again. If the value is the same as previously read, the value of oldBut will be updated and the LED will blink the number of times implied by the binary value of the two switches. Note the inversion of the value since a switch that is "on" reads LO. The switches will be scanned continuously for further changes.
Please refer to earlier Instructables by The Real Elliot to learn more about blinkenlights. Have a look at this
http://www.ganssle.com/debouncing.pdf to learn more about debouncing switches.
Here's the ATtiny2313 code for this example. In operation, this program will blink the LED on PB4 (physical pin 8) twice to show it is initialized. It will then read switches one and two, and blink one to three times depending on the switch setting whenever they are changed. When the switches are not changing, the LED will blink slowly.
To run this code, create a new directory (call it "Basic" if you like) and download the following C code file and makefile into it. Rename Makefile1.txt to just Makefile. Using WinAVR, compile the program and load it into your ATtiny2313.