Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- petracar
- Date:
- 2019-11-16
- Revision:
- 0:9f18a15996c8
File content as of revision 0:9f18a15996c8:
#include "mbed.h"
#include "semafor.h"
Traffic crveno (p7);
Traffic zuto (p6);
Traffic zeleno (p5);
Traffic zeleno_p (p20);
Traffic crveno_p (p19);
InterruptIn tipkalo(p8);
Ticker tik1;
int t=0,p;
void tiker1(){
t=t+1;
}
void pjesaci(){
p=1;
}
void semafor2(){
if(t>=0 && t<200)
zeleno.light_on(t, 0, 200);
crveno_p.light_on(t, 0, 400);
if(t>=200 && t<400)
zuto.light_on(t, 200, 400);
if(t>=400 && t<700){
crveno.light_on(t, 400, 700);
zeleno_p.light_on(t, 400, 500);}
if(t>=600 && t<700)
zuto.light_on(t,600, 700);
if (t>=500)
crveno_p.light_on(t,500,700);
}
int main(){
tik1.attach(&tiker1, 0.01);
while(1){
if(p!=1)
t=0;
zeleno.light_on(t, 0, 1);
crveno_p.light_on(t, 0, 1);
tipkalo.fall(&pjesaci);
if(p==1 && t<700)
semafor2();
if(p==1 && t>700){
t=0;
p=0;
}
}
}