I am working on a program that takes an input from a switch (connected to P0.0) and causes 4 LEDs to blink. I am using an Atmel 8051 microcontroller. The idea is that if P0.0 is one then the LEDs will blink from lowest to highest with a .25 second delay between blinks. Only one LED will be on at a time. If P0.0 is zero then the LEDs will blink from highest to lowest with a .25 seconds delay. Only one LED will be on at a time.
The LEDs are connected to P1.0, P1.1, P1.2, P1.3.
I have written a program in C that does exactly what the above states. I used a continuos loop that had 2 if statements in it. if(P0_0 ==0) and if(P0_0 ==1) to check the input from the switch. Each of these if statments then had code to turn a specific port on/off and delay a certain amount of time.
My question is how would i write the code to use one of the controllers onboard timers to set the blinking delay to .25 seconds. Would i be in Timer mode 0 or 1? Would i have the clock single or double clocked?
The crystal speed we are using is 28.2076 MHz
Any information would be extremely helpful. Thanks in advance