LV03_US_Grupa03_Tim07_Zadatak01 Haris Imamovic Halilbegovic Kemal

Dependencies:   N5110 mbed

Fork of US2016_LV3_Z1 by Emir Sokic

Committer:
2016US_HarisImamovic
Date:
Mon Mar 21 17:48:54 2016 +0000
Revision:
2:369ce3ec6248
Parent:
1:8ddf3a73e99e
LV03_US_Grupa03_Tim07_Zadatak01;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
esokic 0:6ebfd28a8b0c 1 #include "mbed.h"
esokic 0:6ebfd28a8b0c 2 #include "N5110.h"
2016US_HarisImamovic 1:8ddf3a73e99e 3 #include "string.h"
esokic 0:6ebfd28a8b0c 4 #define dp23 P0_0
esokic 0:6ebfd28a8b0c 5
2016US_HarisImamovic 1:8ddf3a73e99e 6 #define STRUJA 0.00033 // 3.3V/10kOhm = 0.33 mA
2016US_HarisImamovic 1:8ddf3a73e99e 7 #define NAPAJANJE 3.3 // Vcc = 3.3V
2016US_HarisImamovic 1:8ddf3a73e99e 8
esokic 0:6ebfd28a8b0c 9 //N5110 lcd(VCC,SCE,RST,DC,MOSI,SCLK,LED));
esokic 0:6ebfd28a8b0c 10 N5110 lcd(dp4,dp24,dp23,dp25,dp2,dp6,dp18);
esokic 0:6ebfd28a8b0c 11
esokic 0:6ebfd28a8b0c 12 DigitalOut enable(dp14);
2016US_HarisImamovic 1:8ddf3a73e99e 13 AnalogIn napon(dp9);
2016US_HarisImamovic 1:8ddf3a73e99e 14 DigitalIn taster(dp1);
2016US_HarisImamovic 1:8ddf3a73e99e 15
2016US_HarisImamovic 1:8ddf3a73e99e 16 char rezultat[5], buffer[5], strBuffer[14];
2016US_HarisImamovic 1:8ddf3a73e99e 17
2016US_HarisImamovic 1:8ddf3a73e99e 18 void ispisiNapon() {
2016US_HarisImamovic 1:8ddf3a73e99e 19 lcd.clear();
2016US_HarisImamovic 1:8ddf3a73e99e 20
2016US_HarisImamovic 1:8ddf3a73e99e 21 float tmp2 = napon*NAPAJANJE;
2016US_HarisImamovic 1:8ddf3a73e99e 22 sprintf(strBuffer, "U = %2.2fV", tmp2);
2016US_HarisImamovic 1:8ddf3a73e99e 23 lcd.printString(strBuffer, 0, 0);
2016US_HarisImamovic 1:8ddf3a73e99e 24
2016US_HarisImamovic 1:8ddf3a73e99e 25 }
2016US_HarisImamovic 1:8ddf3a73e99e 26
2016US_HarisImamovic 1:8ddf3a73e99e 27 void ispisiOtpor() {
2016US_HarisImamovic 1:8ddf3a73e99e 28 lcd.clear();
2016US_HarisImamovic 1:8ddf3a73e99e 29
2016US_HarisImamovic 1:8ddf3a73e99e 30 float tmp = (napon/STRUJA)*NAPAJANJE;
2016US_HarisImamovic 1:8ddf3a73e99e 31 sprintf(strBuffer, "R = %2.2fO", tmp);
2016US_HarisImamovic 1:8ddf3a73e99e 32 lcd.printString(strBuffer, 0, 0);
2016US_HarisImamovic 1:8ddf3a73e99e 33 }
2016US_HarisImamovic 1:8ddf3a73e99e 34
2016US_HarisImamovic 1:8ddf3a73e99e 35
2016US_HarisImamovic 1:8ddf3a73e99e 36 int counter = 0;
2016US_HarisImamovic 1:8ddf3a73e99e 37
2016US_HarisImamovic 1:8ddf3a73e99e 38 void klik() {
2016US_HarisImamovic 1:8ddf3a73e99e 39 if(counter%2 == 1) {
2016US_HarisImamovic 1:8ddf3a73e99e 40 ispisiNapon();
2016US_HarisImamovic 1:8ddf3a73e99e 41 wait(0.4);
2016US_HarisImamovic 1:8ddf3a73e99e 42 }
2016US_HarisImamovic 1:8ddf3a73e99e 43 else {
2016US_HarisImamovic 1:8ddf3a73e99e 44 ispisiOtpor();
2016US_HarisImamovic 1:8ddf3a73e99e 45 wait(0.4);
2016US_HarisImamovic 1:8ddf3a73e99e 46 }
2016US_HarisImamovic 1:8ddf3a73e99e 47 }
esokic 0:6ebfd28a8b0c 48
esokic 0:6ebfd28a8b0c 49 int main() {
2016US_HarisImamovic 1:8ddf3a73e99e 50 enable = 1;
2016US_HarisImamovic 1:8ddf3a73e99e 51 lcd.init();
2016US_HarisImamovic 1:8ddf3a73e99e 52
2016US_HarisImamovic 1:8ddf3a73e99e 53 while(1) {
2016US_HarisImamovic 1:8ddf3a73e99e 54 if(taster == 1) counter++;
2016US_HarisImamovic 1:8ddf3a73e99e 55 klik();
2016US_HarisImamovic 1:8ddf3a73e99e 56 wait(0.2);
2016US_HarisImamovic 1:8ddf3a73e99e 57 }
esokic 0:6ebfd28a8b0c 58 }