Created
October 7, 2015 18:14
-
-
Save JHeld07/ce637a24b9e8cd33e3ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <18f4520.h> | |
#use delay(clock=20000000) | |
#fuses HS, NOWDT, NOLVP | |
#include "../Library/18f4520ptr.h" | |
#include "../Library/KeypadC1.h" | |
#include "../Library/modifiedlcd.h" | |
float Vres=6.0/1023.0; | |
float Voltage; | |
float Vmin=3; | |
#INT_AD | |
void int_ad_isr(){ | |
Voltage=*Q*Vres-Vmin; | |
} | |
main(){ | |
char press1, press2, press3; | |
lcd_init(); | |
ADCON0->ADON=1; | |
ADCON0->CHSx=0; | |
ADCON1->PCFGx=0x0F; | |
*TRISA=0x0F; // A0 input | |
*TRISB=0xF0; | |
*TRISC=0x00; | |
ADCON2->ADFM=1; //RJ | |
//Enable References | |
ADCON1->VCFG0=1; | |
ADCON1->VCFG1=1; | |
//Interupt Setup | |
PIE1->ADIE=1; | |
INTCON->GIE=1; | |
INTCON->PEIE=1; | |
INTCON2->RBPU=0; | |
while(1){ | |
//Keypad | |
press1=KeyPress(); | |
press2+=press1; //???? | |
if(press1!='@'){ | |
printf(lcd_putc,"\f %c %c", press1, press2); //\n prints and clears line 2. \f prints anc clears line 1. | |
// printf(lcd_putc,"\n %c", press2); // test line to see what is being execpted press1 vs press2 | |
} | |
press2=press1; | |
//pot | |
printf(lcd_putc,"\n %fV", Voltage); | |
ADCON0->GODONE=1; //Go | |
delay_ms(300); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment