C programming doubt

Thread Starter

jimmyvarghese

Joined Nov 25, 2009
2
Help me.....


include<stdio.h>


void main()

{
int i;
char map[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6 F};
TRISD=0x00;
TRISC=0x00;
TRISB=0X00;
TRISA=0XF0;
RC1=0;
i=0;

while(i<9)
{
i++;
PORTD=map;
PORTB=0x01;
_delay(196999);
PORTB=0x00;
_delay(196999);
RC1=1;
//RB5=1;
RC0=0;
}



this program is working in good condition.but i want add a switch control to it.now it is increament continuously.so i want to change this one as when we press the push button
then only the increment happen



http://www.electro-tech-online.com/attachments/micro-controllers/39578d1267253908-help-me-116.pdf


 

andrew24

Joined Aug 20, 2008
76
Hello, one possibility is to create an interrupt from a pin where a button is conected (don't know is that possible with PIC, never worked with it) and in the ISR write some_kind_of_variable++ or something else you want, or in the endless loop check the state of o GPIO (if PIN==0..).
In both techniques, you have to connect one side of a pin to ground, and other to GPIO/IRQ pin through a pullup resistor.
 
Last edited:
Top