Professional Documents
Culture Documents
Lab 7: Additional Two External Leds and Two External Push Buttons For Elab16M
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.
5. Add Goto icon after Icon 5. Then add Label icon after Icon 6 and rename it as Again2.
THEN
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.
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.