Quantcast
Channel: LED Projects - PIC Microcontroller
Viewing all articles
Browse latest Browse all 387

How to take input with PIC18F4550 Microcontroller

$
0
0

Any microcontroller based system typically has an input and a corresponding output. Taking simple output with a PIC microcontroller has been explained in LED blinking with PIC18F4550. This article explains how to provide an input to the controller and get a corresponding output using PIC18F4550.

PIC18F4550 has a total of 35 I/O (input-output) pins which are distributed among 5 Ports. Each Port of a PIC microcontroller corresponds to three 8-bit registers (TRIS, PORT & LAT) which should be configured to use the Port for general I/O purpose. For more details, refer LED blinking using PIC.

 LED-Switch
To configure a particular port/pin as input, the corresponding TRIS register/TRIS bit should be set to high (1). For output, the relevant TRIS register/bit should be set to low (0).
For example, for PortD
·         To set the entire PortD as input
TRISD
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value
1
1
1
1
1
1
1
1
 
·         To set only 3rd pin (RD2) of PortD as input
TRISD
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value
1
 

·         To set  1st pin (RD0) as output and 4th pin (RD3) of PortD as input

 

For more detail: How to take input with PIC18F4550 Microcontroller

The post How to take input with PIC18F4550 Microcontroller appeared first on PIC Microcontroller.


Viewing all articles
Browse latest Browse all 387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>