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 Adafruit_GFX DS1820
Revision 13:d2c49ef3b2ac, committed 2021-12-14
- Comitter:
- davidmateos
- Date:
- Tue Dec 14 12:27:41 2021 +0000
- Parent:
- 12:71ae2f729b7f
- Child:
- 14:21cb6b2ac16b
- Commit message:
- ULTIMA ACT
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Dec 14 11:31:12 2021 +0000
+++ b/main.cpp Tue Dec 14 12:27:41 2021 +0000
@@ -24,6 +24,9 @@
Serial pc(USBTX, USBRX); // tx, rx
+//Serial bt(D1, D0); // tx, rx
+
+
Ticker tickerMideDistancia;
unsigned distancia=20;
@@ -41,9 +44,15 @@
float temp = 0;
int contador=0;
-// control aplicacion
-int x=0;
-int y=1;
+
+int x=1;
+int y=0;
+//if (x==1){
+ //y=0;
+ // }else{
+ // y=1;
+ // }
+
////////////////
Timer tiempo;
@@ -77,7 +86,10 @@
//distancia < 5
- }
+ }else if(contador==3){
+ y=1;
+ x=0;
+ }
}
if(x==0 &&y==0){
pc.printf("No seleccionado programa\r\n");
@@ -94,6 +106,7 @@
}
}
+
}
void estadoAbriendose()
@@ -132,7 +145,7 @@
}
}
-
+
}
@@ -150,7 +163,7 @@
}
}
-
+
}
@@ -168,8 +181,12 @@
contador++;
gOled.clearDisplay();
gOled.printf("piezas transportadas %d\n",contador);
+ gOled.printf("temp = %3.1f C\r\n", temp);
gOled.display();
gOled.setTextCursor(0,0);
+
+
+
}
int main()
@@ -181,6 +198,7 @@
gOled.clearDisplay();
gOled.printf("Hola\n");
gOled.display();
+ //x=(pc.getc());
//pc.printf("Estado cerrada\n");
if(x==1){
gOled.clearDisplay();
@@ -200,6 +218,8 @@
if(ds1820.begin()) {
while(1) {
+
+
ds1820.startConversion(); // start temperature conversion from analog to digital
wait(1.0); // let DS1820 complete the temperature conversion
error = ds1820.read(temp); // read temperature from DS1820 and perform cyclic redundancy check (CRC)
@@ -233,6 +253,9 @@
// led=0;
// wait(1.0);
//
+ if(pc.readable()) {
+ x=(pc.getc());
+ }
switch ( estado ) {
case cerrada: