Line 4: Line 4:
  
 
=Steps=
 
=Steps=
#Configure the PORTS as outputs using TRIS registers.
+
#Configure the PORT D0 as outputs using TRIS registers.
#Turn ON all the LEDs and wait for some time.
+
#Configure the PORT D2 as input using TRIS registers.
#Turn OFF all the LEDs and wait for some time.
+
#Read the switch status.
 +
#ON/OFF the led as per switch status.
  
 
=Code=
 
=Code=

Revision as of 16:31, 27 April 2016

In this tutorial we will learn how to ON OFF LED with Switch on PIC16F877 Starter Board.
The Explore Starter PIC board has two on board LED's which are connected to PORT D0 and PORT D1 and two on board Switches which are connected to PORT D2 and PORT D3.

Steps

  1. Configure the PORT D0 as outputs using TRIS registers.
  2. Configure the PORT D2 as input using TRIS registers.
  3. Read the switch status.
  4. ON/OFF the led as per switch status.

Code

Demo

PIC16f877A LED Switch.gif