Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need C code for PIC16F84A with switches, 7 Segment display

Status
Not open for further replies.

amanmathur07

Newbie level 1
Joined
Apr 27, 2010
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,286
PIC16F84A

I'm want to count the number of swiches on (5V) on port a on a pic16f84a. on port b, I have a seven segment display where the number should be displayed. I need help writing the c code
 

Code:
//include file
#include <pic.h>

//16F84 configuration 
__CONFIG(0x3FF1);

//defining the switches
#define PORTBIT(adr, bit)	((unsigned)(&adr)*8+(bit))


//display function
 send_7_seg(int);


//main function
void main(void)
{	

	TRISA = 0x01;
	PORTA = 0b00000000;	
	
	while(1)
	{

		for(int a=0; a<8; a++)
		{
                                   if ( PORTBIT(PORTA, a)==1){
                                            send_7_seg(a);
		
		};

	}

}

void  send_7_seg(int seg_num)
{
     TRISB = 0x00;
     PORTB = 0b00000000;
//you should write here to send your data to display
	
};

//i didnt simulate this program and i am not very good at pics but it could help you 
//to build you project
//if you want more help, dont hesitate to send ne a private message

Added after 1 minutes:

and please dont copy-paste i could have made some mistakes
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top