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
Diff: main.cpp
- Revision:
- 8:a071c579f9ea
- Parent:
- 7:296b42f24d44
- Child:
- 9:d651ed116942
--- a/main.cpp Mon Dec 13 20:03:11 2021 +0000
+++ b/main.cpp Mon Dec 13 20:12:05 2021 +0000
@@ -1,7 +1,10 @@
#include "mbed.h"
#include "hcsr04.h"
+
+
+
#include "Adafruit_SSD1306.h"
-
+
class I2CPreInit : public I2C
{
public:
@@ -11,13 +14,14 @@
start();
};
};
-
-
+
+
I2CPreInit gI2C(PB_9,PB_8);
-
+
// an SPI sub-class that provides a constructed default
-
+
Adafruit_SSD1306_I2c gOled(gI2C,NC,0x78,64,128);
+Serial pc(USBTX, USBRX);
Serial pc(USBTX, USBRX); // tx, rx
Ticker tickerMideDistancia;
@@ -64,12 +68,6 @@
//distancia < 5
}
- if(contador==3){
- gOled.clearDisplay();
- gOled.printf("Proceso terminado\n");
-
- gOled.display();
- }
}
@@ -119,31 +117,18 @@
//}
contador++;
- gOled.clearDisplay();
- gOled.printf("Proceso en marcha\n");
- gOled.printf("Piezas transportadas %d\n",contador);
- gOled.display();
- gOled.setTextCursor(0,0);
- //wait(1.000);
-
}
int main()
{
pc.baud(115200);
tickerMideDistancia.attach(&mideDistancia, 0.5);
- gOled.begin();
- gOled.clearDisplay();
estado=cerrada;
//pc.printf("Estado cerrada\n");
- gOled.printf("Buenos dias\n");
- gOled.display();
-
-
+
while(1) {
distancia=usensor.get_dist_cm();
-
switch ( estado ) {
case cerrada:
estadoCerrada();
@@ -159,10 +144,6 @@
break;
default:
break;
-
}
-
-
}
-
}