Page 1 of 1

How to use single input & output on 16F84A microcontroler

Posted: Fri Sep 28, 2012 7:14 pm
by nuwan1131
16f84a pic 1 ta input signal1 deela output1 labagenima sada program1 liyanne kohomada?saralawa pehedili kara denna

[ Post made via Mobile Device ] Image

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

Posted: Mon Oct 01, 2012 2:37 am
by Neo
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;
}