Skip to content

Instantly share code, notes, and snippets.

@JHeld07
Created December 16, 2015 00:15
Show Gist options
  • Save JHeld07/f0f256e4ff6c92a709f6 to your computer and use it in GitHub Desktop.
Save JHeld07/f0f256e4ff6c92a709f6 to your computer and use it in GitHub Desktop.
Enter file contents here#include <18f4520.h>
#use delay(clock=20000000)
#fuses HS, NOWDT, NOLVP
#include "../Library/18f4520ptr.h"
#include "../Library/Keypad.h"
#include "../Library/modifiedlcd.h"
main(){
int16 press1, press2;
lcd_init();
*TRISB=0xF0;
*TRISC=0x00;
ADCON1->PCFGx=0x0F;
INTCON2->RBPU=0;
while(1){
press1=(int16)KeyPress()-0x30; //Takes the ASCII value from the keypress and removes the hex value.
if(press1<=9 && press1>=0){ // Filters out any value other than 0-9
press2=((press2*10)+press1); // Takes the first press, saves it for use when adding press1 to press2
if(press2>100){ // if the press2 value is greater than 100 reset press2 to 0 value.
press2=0;
}
}
printf(lcd_putc,"\n %lu", press2); //Print Pot voltage, print keypad value.
delay_ms(300);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment