Marko_Marinic_0246048959
Dependencies: mbed SeeedShieldBot TextLCD BluetoothSerial
Pametni stubišni automat je uređaj koji služi za paljenje svjetala pomoću pljeska. Rasvjetu predstavljaju četiri LED diode koje se pale jedna za drugom. Pale se u vremenskom razmaku koji odbrojava 8 segmentni displej. Gase se isto u vremenskom razmaku ( odbrojavanja na displeju) istim redom kako su se i palile. LCD zaslon služi za prikaz detekcije pljeska. Tipkalo služi kao START gumb.
Revision 0:0b3b22a12941, committed 2021-07-13
- Comitter:
- mmarinic
- Date:
- Tue Jul 13 15:31:59 2021 +0000
- Commit message:
- Pamteni stubisni automat
Changed in this revision
diff -r 000000000000 -r 0b3b22a12941 BluetoothSerial.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BluetoothSerial.lib Tue Jul 13 15:31:59 2021 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/yihui/code/BluetoothSerial/#f56002898ee8
diff -r 000000000000 -r 0b3b22a12941 SeeedShieldBot.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SeeedShieldBot.lib Tue Jul 13 15:31:59 2021 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/components/code/SeeedShieldBot/#9fd1722259a1
diff -r 000000000000 -r 0b3b22a12941 SegDisplay.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SegDisplay.cpp Tue Jul 13 15:31:59 2021 +0000 @@ -0,0 +1,21 @@ +#include "SegDisplay.h" +BusOut Seg(D2,D3,D4,D5,D6,D7,D8,D9); +void SegInit(void) { +Seg=SegConvert(0); +} +char SegConvert(char SegValue) { +char SegByte=0x00; +switch (SegValue) { //DP G F E D C B A +case 0 : SegByte = 0x3F; break; // 0 0 1 1 1 1 1 1 binary +case 1 : SegByte = 0x06; break; // 0 0 0 0 0 1 1 0 binary +case 2 : SegByte = 0x5B; break; // 0 1 0 1 1 0 1 1 binary +case 3 : SegByte = 0x4F; break; // 0 1 0 0 1 1 1 1 binary +case 4 : SegByte = 0x66; break; // 0 1 1 0 0 1 1 0 binary +case 5 : SegByte = 0x6D; break; // 0 1 1 0 1 1 0 1 binary +case 6 : SegByte = 0x7D; break; // 0 1 1 1 1 1 0 1 binary +case 7 : SegByte = 0x07; break; // 0 0 0 0 0 1 1 1 binary +case 8 : SegByte = 0x7F; break; // 0 1 1 1 1 1 1 1 binary +case 9 : SegByte = 0x6F; break; // 0 1 1 0 1 1 1 1 binary +} +return SegByte; +} \ No newline at end of file
diff -r 000000000000 -r 0b3b22a12941 SegDisplay.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SegDisplay.h Tue Jul 13 15:31:59 2021 +0000 @@ -0,0 +1,7 @@ +#ifndef SEGDISPLAY_H +#define SEGDISPLAY_H +#include "mbed.h" +extern BusOut Seg; // allow Seg to be manipulated by other files +void SegInit(void); // function prototype +char SegConvert(char SegValue); // function prototype +#endif \ No newline at end of file
diff -r 000000000000 -r 0b3b22a12941 Stanovi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Stanovi.cpp Tue Jul 13 15:31:59 2021 +0000 @@ -0,0 +1,28 @@ +#include "Stanovi.h" +BusOut Stanovi(D10,D11,D12,D14); +void StanoviInit(void) { +Stanovi=BrojStanova(0);// initialise to zero +Stanovi=ObrnutoBrojStanova(0); +} +int BrojStanova(int Broj){ + int StanByte=00; + switch (Broj) { + case 0 : StanByte = 00;break; // 00000 binary + case 1 : StanByte = 01;break; // 00001 binary + case 2 : StanByte = 03;break; // 00011 binary + case 3 : StanByte = 07;break; // 00111 binary + case 4 : StanByte = 15;break; // 01111 binary + } + return StanByte; + } +int ObrnutoBrojStanova(int Broj){ + int StanByte=00; + switch (Broj) { + case 0 : StanByte = 00;break; // 00000 binary + case 1 : StanByte = 8;break; // 01000 binary + case 2 : StanByte = 12;break; // 01100 binary + case 3 : StanByte = 14;break; // 01110 binary + case 4 : StanByte = 15;break; // 01111 binary + } + return StanByte; + } \ No newline at end of file
diff -r 000000000000 -r 0b3b22a12941 Stanovi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Stanovi.h Tue Jul 13 15:31:59 2021 +0000 @@ -0,0 +1,8 @@ +#ifndef STANOVI_H +#define STANOVI_H +#include "mbed.h" +extern BusOut Stanovi; // allow Seg to be manipulated by other files +void StanoviInit(void); // function prototype +int BrojStanova(int Broj); // function prototype +int ObrnutoBrojStanova(int Broj); +#endif \ No newline at end of file
diff -r 000000000000 -r 0b3b22a12941 TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Tue Jul 13 15:31:59 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/tlunzer/code/TextLCD/#a7c08c5305b3
diff -r 000000000000 -r 0b3b22a12941 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jul 13 15:31:59 2021 +0000 @@ -0,0 +1,57 @@ +#include "mbed.h" +#include "TextLCD.h" +#include "SegDisplay.h" +#include "Stanovi.h" +Serial pc(USBTX, USBRX); +TextLCD ZaslonLCD(PA_0, PA_1, PA_4, PB_0, PC_1, PC_0, TextLCD::LCD16x1); +AnalogIn AnalogniUlaz(D13); +float JacinaZvuka; +InterruptIn StartGumb(D15); +void Glavna(void); +Timer tajmer; +int main() { + tajmer.start(); + StartGumb.rise(&Glavna); +} +void Glavna() { + if (tajmer.read_ms()>200) { + SegInit(); + StanoviInit(); + ZaslonLCD.printf("\nMRAK!!!"); + while(1){ + int brojac1 = 0; + int brojac2 = 4; + JacinaZvuka=abs(AnalogniUlaz-0.064); + if(JacinaZvuka>0.1){ + ZaslonLCD.printf("\nPLJESAK!!!"); + for(int i =0;i<=10;i++){ + if(i==10){ + if(brojac2>3){ + brojac1++; + Stanovi=BrojStanova(brojac1); + i=0; + } + if(brojac1>=5){ + brojac2--; + Stanovi=ObrnutoBrojStanova(brojac2); + if(brojac2==0){ + brojac1=0; + brojac2=5; + Seg=SegConvert(0); + ZaslonLCD.printf("\nMRAK!!!"); + break; + } + i=0; + } + } + Seg=SegConvert(i); + wait(0.3); + } + } + pc.printf("JacinaZvuka... \n\r"); + pc.printf("%f \n\r",JacinaZvuka); + } +} +} + +
diff -r 000000000000 -r 0b3b22a12941 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Jul 13 15:31:59 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file