For this week I tried to use all the free pins of the tiny 44 microcontroller and added a switch and 3 LED.
My initial intention was to make traffic light with green yellow and red LED one on top of the other.
I put a lot of effort in arranging the traces so that the LED will have this certain configuration.
Eventually, I couldn’t find a yellow LED so I put a red one instead.
I put the switch in a opposing side of the LED so the thumb pressing the LED will not block the LED as it lit.
This is what the my board does:
This is the Eagle scheme file I made for the tracing the board:
This is the Eagle tracing of the board. I used a zero Ω resistor to solve the traces "puzzle" with the configuration I wanted.
I programmed the MC using C language based on the Hello FDTI example and the help from Brian.
This is the main part of the code :
static int buttonPress;
static int buttonUpTest;
buttonPress=0;
buttonUpTest=1;
index = 0;
static int i;
// indication of initial power connections
set(TopLEDport,TopLEDpin);
set(MidLEDport,MidLEDpin);
set(BottomLEDport,BottomLEDpin);
_delay_ms(100);
clear(TopLEDport,TopLEDpin);
clear(MidLEDport,MidLEDpin);
clear(BottomLEDport,BottomLEDpin);
while (1) {
// checking if the button pressed
// and adding 1 to the index only if it is not a continous press
if (pin_test(SwitchInput,SwitchPin)==0){
if (buttonUpTest){
buttonPress=buttonPress+1;
}
buttonUpTest=0;
}else{
buttonUpTest=1;
}
//checking the index and taking action
if (buttonUpTest){
switch( buttonPress )
{
case 1:
set(TopLEDport,TopLEDpin);
break;
case 2:
set(MidLEDport,MidLEDpin);
break;
case 3:
set(BottomLEDport,BottomLEDpin);
break;
case 4:
// on the forth press, blinking and zeroing
buttonPress=0;
for ( i=0;i<=3;i=i+1){
set(TopLEDport,TopLEDpin);
set(MidLEDport,MidLEDpin);
set(BottomLEDport,BottomLEDpin);
_delay_ms(100);
clear(TopLEDport,TopLEDpin);
clear(MidLEDport,MidLEDpin);
clear(BottomLEDport,BottomLEDpin);
_delay_ms(100);
}
break;
}
}
}