LV3 ZAD1 Adam Stanic i Benjamin Hrustemovic
Fork of US2016_LV3_Z1 by
Revision 1:ad99623f0117, committed 2016-03-19
- Comitter:
- 2016US_AdamStanic
- Date:
- Sat Mar 19 12:38:08 2016 +0000
- Parent:
- 0:6ebfd28a8b0c
- Commit message:
- LV3 ZAD1 Adam Stanic i Benjamin Hrustemovic
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6ebfd28a8b0c -r ad99623f0117 main.cpp --- a/main.cpp Wed Mar 09 08:30:01 2016 +0000 +++ b/main.cpp Sat Mar 19 12:38:08 2016 +0000 @@ -1,22 +1,53 @@ #include "mbed.h" #include "N5110.h" -#define dp23 P0_0 +#include "string.h" -//N5110 lcd(VCC,SCE,RST,DC,MOSI,SCLK,LED)); +#define dp23 P0_0 +#define OTPOR 10000 +#define NAPON 3.3 + N5110 lcd(dp4,dp24,dp23,dp25,dp2,dp6,dp18); DigitalOut enable(dp14); +AnalogIn napon(dp9); +DigitalIn taster1(dp1); + + int main() { - - //deaktivacija led dioda + float otpor(0); enable=1; - - //inicijalizacija displeja lcd.init(); + lcd.printString("Napon: ",0,0); + lcd.printString("Otpor: ",0,1); - //prikaz stringa - lcd.printString("Mi volimo US!",0,0); + int brojac=0; + - while(1); -} + while(1) { + + if(taster1==1) brojac++; + if(brojac>1) brojac=0; + + + + otpor=napon*10000; + + if(brojac==1){ + lcd.clear(); + char str_napon[6]; + sprintf(str_napon,"%.2f",(float)napon*3.3); + str_napon[5]='\0'; + lcd.printString(str_napon,50,0); + } + + if(brojac==0){ + lcd.clear(); + char str_otpor[6]; + sprintf(str_otpor,"%.2f",otpor); + str_otpor[5]='\0'; + lcd.printString(str_otpor,50,1); + } + wait(0.5); + } +} \ No newline at end of file