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 Servo mbed-rtos beep hcsr04 TextLCD
Revision 2:33e2a092cab6, committed 2019-03-27
- Comitter:
- CiroSamu
- Date:
- Wed Mar 27 11:32:56 2019 +0000
- Parent:
- 1:13556d8b4a34
- Child:
- 3:272fb57c7fcb
- Commit message:
- progetto
Changed in this revision
--- a/HCSR04.lib Tue Mar 26 11:09:02 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://developer.mbed.org/users/prabhuvd/code/HCSR04/#71da0dbf4400
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hcsr04.lib Wed Mar 27 11:32:56 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/ITI-DallaChiesa1/code/hcsr04/#568f3374c9a7
--- a/main.cpp Tue Mar 26 11:09:02 2019 +0000 +++ b/main.cpp Wed Mar 27 11:32:56 2019 +0000 @@ -4,32 +4,17 @@ #include "beep.h" /******************************/ //bluetooth -Serial blue(D10,D2);//tx e rx +Serial pc(USBTX, USBRX);//tx e rx /******************************/ //sensori ad ultrasuoni HCSR04 sensor1(D15, D14); //istanza oggetti "sensori" HCSR04 sensor2(D12, D13); -HCSR04 sensor3(D11, D9); -/******************************/ -//dichiarazioni led -//Led per le macchine -DigitalOut rossoC(PA_0); //istanza oggetti "led" -DigitalOut gialloC(D5); -DigitalOut verdeC(D3); -/******************************/ -//led per i pedoni -DigitalOut rossoP(D6); //istanza oggetti "led specifici per i pedoni" -DigitalOut gialloP(D7); -DigitalOut verdeP(D8); -/******************************/ -//buzzer -Beep buzzer(D4); //istanza oggetti "buzzer" -/******************************/ +//HCSR04 sensor3(D11, D9); /******************************/ Thread thread_sensori; // istanzia oggetto thread -bool occupata = false; +bool occupata[2] = {false}; /******************************/ //sensore semaforo 1 @@ -38,24 +23,30 @@ sensor1.start(); wait_ms(100); sensor2.start(); //partono i sensori - wait_ms(100); - if(sensor1.get_dist_cm() < 5 && occupata[0] = false){ //se uno dei sensori capta una distanza minore 10 + wait_ms(100); + sensor1.get_dist_cm(); + sensor2.get_dist_cm(); + if(sensor1.get_dist_cm() < 5 && occupata[0] == false) //se uno dei sensori capta una distanza minore 10 occupata[0] = true; else occupata[0] = false; - if(sensor2.get_dist_cm() < 5 && occupata[1] = false){ //se uno dei sensori capta una distanza minore a 10 e gianello è false + + if(sensor2.get_dist_cm() < 5 && occupata[1] == false) //se uno dei sensori capta una distanza minore a 10 e gianello è false occupata[1] = true; else occupata[1] = false; - } + } int main(){ - int i; + pc.printf("prova"); while(true) { - //if (mybutton) { + + sensori(); + // blue.printf("prova"); + //if (mybutton) { for (int i = 0; i < 2; i++) pc.printf("%d", occupata[i]); - + } @@ -64,6 +55,7 @@ } -void thread_sensori() { +//void thread sensori() { -} \ No newline at end of file + +//} \ No newline at end of file