Ivan Jajčević
/
projekt
Pametna_kuca
Revision 2:4379fe6ea43b, committed 2021-03-02
- Comitter:
- ijajcevic
- Date:
- Tue Mar 02 22:39:08 2021 +0000
- Parent:
- 1:9e5c378547dc
- Commit message:
- Pametna_kuca
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/blinkalo.lib Tue Mar 02 22:39:08 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/ijajcevic/code/blinkalo/#cf737240fac5
--- a/main.cpp Mon Mar 01 19:21:54 2021 +0000 +++ b/main.cpp Tue Mar 02 22:39:08 2021 +0000 @@ -5,6 +5,7 @@ #include "mbed.h" #include "TextLCD.h" #include "pcinput.h" +#include "blinkalo.h" PwmOut PWM1(PC_8); Timer debounce; @@ -23,6 +24,12 @@ int prva(int k, int x); // inicijalizacija funkcije prva int druga(int l, int x); // inicijalizacija funkcije druga +blinkalo cctv(PB_8); + +void flip1() +{ + ledica1 = !ledica1; +} int main() { @@ -35,6 +42,7 @@ int i=1; int k=1; int l=1; + gumb.mode(PullUp); PWM1.period(0.01); @@ -43,9 +51,10 @@ lcd.locate(0,0); lcd.printf("Vrijednost pwm:"); flipper1.attach(&flip1, 0.2); - + cctv.blink(2); while (1) { char c; + if (pc.readable()){ c = KeyInput(); //vuče iz pcinput.cpp pc.printf("Vrijednost PWM-a: %f\n\r",1-f);
--- a/pcinput.cpp Mon Mar 01 19:21:54 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -// input s tikovnice -#include "pcinput.h" -Serial pc(USBTX, USBRX); // komunikacija s recunalom -void inicijalizacija(void) -{ - pc.printf("\n\r Unesi vrjednost:\n\r"); -} -char KeyInput(void) -{ - char c = pc.getc(); // dobivanje ulaza s tikovnice - int uvijet; - uvijet = c; - if (uvijet < 48 ){ - c = 48; - } - if (uvijet > 58){ - c = 58; - } - pc.printf("%c",c); // isprintaj na teraterm - return (c); // vrati vrijednost znaka -} \ No newline at end of file
--- a/pcinput.h Mon Mar 01 19:21:54 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -// pcinput.h za mikoupravljace -#ifndef PCINPUT_H -#define PCINPUT_H -#include "mbed.h" -extern Serial pc; // dopustanje manipulacije iz vana -void inicijalizacija(void); // funkcija -char KeyInput(void); // funkcija -#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pcinput.lib Tue Mar 02 22:39:08 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/ijajcevic/code/pcinput/#0c7e0cd456ba