DIGITALESAVANZADOS

Dependencies:   mbed Servo HC-SR04 TextLCD max6675

Revision:
0:834b339f5f94
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 09 23:50:25 2020 +0000
@@ -0,0 +1,86 @@
+#include "mbed.h"
+#include "HCSR04.h"
+#include "rtos.h"
+#include "Servo.h"
+#include "max6675.h"
+#include "TextLCD.h"
+
+HCSR04 ultrasonido(PTA7,PTA6);
+Servo servomotor(PTA13);
+I2C i2c_lcd(D7,D6);
+TextLCD_I2C lcd(&i2c_lcd, 0x4E,  TextLCD::LCD16x2, TextLCD::HD44780);
+max6675 sensor(D12,D13,D5);
+Serial pc(USBTX,USBRX);
+Thread thread;
+Thread thread1;
+Thread thread2;
+Thread thread3;
+
+void pantallalcd(){
+    lcd.setMode(TextLCD::DispOn);
+    lcd.setBacklight(TextLCD::LightOn);
+    lcd.setCursor(TextLCD::CurOff_BlkOff);
+    }
+    
+void temp_hora()
+{
+    set_time(1256729737);
+    int cf = 0;
+    while (1) {
+        time_t seconds = time(NULL);
+        float temp = sensor.gettemp(cf);
+        printf("%d", seconds);
+        printf("Fecha= %s", ctime(&seconds));
+
+        char buffer[32];
+        strftime(buffer, 32, "%H:%M:%S   ", localtime(&seconds));
+        printf("%s", buffer);
+
+        printf("%4.2f%cF \n\033[2K\033[1A",temp,176);
+        lcd.locate(0,0);
+        lcd.printf("temp:%1.2f\n",temp);
+            
+        Thread::wait(1000);
+    }
+}
+
+void servo()
+{
+
+    servomotor.calibrate(0.001, 180);
+
+    while(1) {
+        for(int i=0; i<100; i++) {
+            servomotor = i*0.01;
+            printf("%d",i);
+            Thread::wait(100);
+        }
+        for(int i=100; i>0; i--) {
+            servomotor = i*0.01;
+            printf("%d",i);
+            Thread::wait(100);
+        }
+    }
+}
+
+void ultra()
+{
+    while(1) {
+        float distancia=ultrasonido.getCm();
+        lcd.locate(0,1);
+        lcd.printf("dist:%2.f cm\n",distancia);
+        Thread::wait(1000);
+    }
+}    
+
+
+   
+int main()
+{
+ 
+    thread.start((ultra));
+    thread1.start ((servo));
+    thread2.start ((temp_hora));
+    thread3.start ((pantallalcd));
+
+}
\ No newline at end of file