Simulacija procesa pranja rublja
Revision 0:c132a33702c3, committed 2022-02-24
- Comitter:
- antep
- Date:
- Thu Feb 24 17:30:39 2022 +0000
- Commit message:
- Konstrukcijski rad "Perilica rublja"
Changed in this revision
program.cpp | Show annotated file Show diff for this revision Revisions of this file |
program.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/program.cpp Thu Feb 24 17:30:39 2022 +0000 @@ -0,0 +1,94 @@ +#include "program.h" +BusOut Display(D1,D11,D12,D15,D14,D13,D10,D9); // -,A,B,C, D,E,F,G +DigitalIn START(USER_BUTTON); +Ticker fault; +PwmOut Zujalo(D5); +InterruptIn vrata(D6,PullUp); + +class LED { +public: +LED(PinName pin) : _pin(pin) +{// _pin(pin) means pass pin to the DigitalOut constructor +_pin = 0; // default the output to 0 +} +void on(int x){ + _pin=x;} +void off(int x){ + _pin=!x;} +private: + DigitalOut _pin; +}; + +LED lijevo(D8); +LED desno(D7); + + +void signalizacija(){ + while(1){ + Zujalo.period(0.002); + Zujalo=0.2; + Display=0xE2; // Fault + lijevo.on(0); + desno.on(0); + wait(1); + Zujalo=0;} + } + + + +void Program(){ +if(START==0&&vrata==0){ +for(int broj=9; broj>=0&&vrata==0; broj--) + { + switch (broj) { + case 0 : + Display = 0x7F; + break; + case 1 : + Display = 0x0C; + break; + case 2 : + Display = 0xB7; + break; + case 3 : + Display = 0x9F; + break; + case 4 : + Display = 0xCC; + break; + case 5 : + Display = 0xDA; + break; + case 6 : + Display = 0xFB; + break; + case 7 : + Display = 0x0F; + break; + case 8 : + Display = 0xFF; + break; + case 9 : + Display = 0xDF; + break; + } + if(int x=broj%2){ + lijevo.on(1); + desno.on(0);} + else{ + lijevo.on(0); + desno.on(1);} + + wait (2); + } +if(vrata==1)fault.attach(&signalizacija,3); +else{ + lijevo.on(0); + desno.on(0); + Zujalo.period(0.0002); + Zujalo=0.6; + wait(2); + Zujalo=0;} +} +return; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/program.h Thu Feb 24 17:30:39 2022 +0000 @@ -0,0 +1,14 @@ +#ifndef program_h +#define program_h +#include "mbed.h" +extern BusOut Display; +extern DigitalIn START; +extern Ticker fault; +extern PwmOut Zujalo; +extern InterruptIn vrata; +void signalizacija(); +void Program(); +#endif + + +