#include <xc.h>
#include "confi.h" // header file for configuration settings.
void delay(unsigned int x);
unsigned int speedstep=0;
void main(void){
unsigned int x,y;
TRISC0=1;
TRISC1=1;
TRISC2=0;
PORTCbits.RC2=0;
while(1){
RC2=1;
delay(y);
RC2=0;
delay(y);
if (PORTCbits.RC0 == 0){ //was the increment button pushed?
for(x=0; x<500; x++); //debounce switch
speedstep++; //increment speedstep variable by 1
y = speedstep;
while(PORTCbits.RC0 == 0);//show variable value on port c
}
if (PORTCbits.RC1 == 0){ //was the decrement button pushed?
for(x=0; x<500; x++); //debounce switch
speedstep--; //deccrement speedstep variable by 1
y = speedstep; //show variable value on port c
while(PORTCbits.RC1 == 0);
}
}
}
void delay(unsigned int x){
for(int i=0; i!=x; i++)
{
NOP();
}
}