Change the world

Control Software

The following example programs are available to demonstrate the basic principles of input, output and delays:

ex1_flash_leds.c

Example program that turns on 8 LEDs for 250ms, then off for 250ms, repeatedly

 

ex2_flash_one_led.c

Example program that turns on an LED for 400ms, then off for 400ms, repeatedly.

 

ex3_sw_leds.c

Reads the value of 8 switches and displays this value on 8 LEDs   

 

ex4_button_led.c

Reads the value of button and then turns an LED on when the button is on otherwise the LED is turned off. 

 

ex5_sw_leds_portb.c

Reads the value of 8 switches on PORTB (using the internal pullup resistors) and displays this value on 8 LEDs. 

 

ex6_sw_leds_truth.c

Reads the value of 3 switches and then controls the output of 8 LEDs as follows:

                  SW2 SW3 SW0 LEDs (0=OFF, 1=ON)

                   0   0   0  00000000

                   0   0   1  00001111

                   0   1   0  11110000

                   0   1   1  11111111

                   1   0   0  10101010

                   1   0   1  10101010

                   1   1   0  10101010

                   1   1   1  10101010

 

ex7_led_count.c

Increments a counter from 0 to 255 repeatedly in 200ms delays and display the count value on 8 LEDs

 

ex8_button_count.c

Increments a counter from 0 to 255 when a button is pushed and released. The count value is displayed on 8 LEDs.  Due to the contact bounce effect on the button, the counter will count fairly inconsistend.  The example ex9_button_count_debounce.c will solve this.

 

ex9_button_count_debounce.c

This is the upgrade of ex8_button_count.c to compensate for the debounce effect on the pushbutton which causes the inconsistend counting.

 

ex10_button_count_function.c

Same as ex9_button_count_debounce.c, but uses a user defined function is_button_pressed() to debounce the input pushbutton's state.