Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 6

LAB 7: Additional two external LEDs and two external Push Buttons for eLab16m.

Assignment: One button as a main switch and other two buttons to control the two external LEDs respectively. In this assignment, we will use two LEDs that will be connected to I/O pin and two external switch to control both LEDs. The hardware connection is as below: a. Connect all the black wires to the - (ground) connector. b. Connect the white wire from the Red LED into A0 connector and the white wire from the Green LED into A2 connector. c. Connect the 3 pin connector of the switch to the pins labeled B0 and another one switch to the pins labeled B1. 1. Open Lab 2 and save as Lab 7. 2. Remain Icons 1,2,3,10 and 11. Delete Icons 4,5,6,7,8 and 9. 3. Choose Decision Icon and insert it after Icon 3. Assign IF PORT B Bit 0 ON.

4. Insert Set/Reset icon after Icon 4. Set PORTA Bit 0 ON.

5. Add Goto icon after Icon 5. Then add Label icon after Icon 6 and rename it as Again2.

THEN

6. Rename the Goto Again Icon 6 as Goto Again2.

7. Insert Decision icon after Icon 7. Set PORTB Bit 1 ON.

Notes: The first Decision Icon is used to control the switch at PORT B Bit 0 while the second Decision Icon is used to control the switch at PORT B Bit 1. 8. Insert Set/Reset icon after Icon 8. Set PORTA Bit 2 ON.

9. Insert GOTO Again Icon after Icon 9.

10. The whole program should look like this:

11. Do not forget to check the chip configuration by double click at Start Icon. Assign PIN 17 (RA0) and PIN 1(RA2) as output pin (arrow pointing out from IC). Assign PIN 6 (RB0) and PIN 7 (RB1) as input pin (arrow pointing into IC)

9. Load the program. Press the Push Button Switch. You will see the red LED will turn on when press the switch at PORT B0 and green LED will turn on when press switch at PORTB1.

You might also like