How to use single input & output on 16F84A microcontroler

Microcontroller Topics
Post Reply
User avatar
nuwan1131
Posts: 2
Joined: Fri Sep 28, 2012 1:17 am

How to use single input & output on 16F84A microcontroler

Post by nuwan1131 » Fri Sep 28, 2012 7:14 pm

16f84a pic 1 ta input signal1 deela output1 labagenima sada program1 liyanne kohomada?saralawa pehedili kara denna

[ Post made via Mobile Device ] Image
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: How to use single input & output on 16F84A microcontroler

Post by Neo » Mon Oct 01, 2012 2:37 am

C valin liyannamko...

Code: Select all

// All standard C includes comes here based on your compiler
// For HI-TECH C, it would be either #include <pic.h> or #include <htc.h>

// Optional: General settings/flags go here

int main (){

	TRISA = 0xFF; // All pins on PORT A are inputs

	TRISB = 0x00;  // All pins on PORT A are outputs
	PORTB = 0x00;

	while (1){
		if (RA0 == 1){ // Check whether RA0 pin is high on PORT A
			RB0 = 1; // Make the RB0 pin high on PORT B
		}
		else{
			RB0 = 0; // Make RB0 pin low on PORT B
		}
	}

	return 0;
}

Post Reply

Return to “Microcontrollers”