Anderson Cunha / Mbed OS example_smart-grid

Dependencies:   sgam-lib

Files at this revision

API Documentation at this revision

Comitter:
AndersonIctus (anderson.ictus@gmail.com)
Date:
Mon May 20 20:59:29 2019 -0300
Parent:
3:a02fcd753ae3
Child:
5:e16fe9e301f9
Commit message:
Inclus?o de um controlador que usa o sensor de temperatura e o LED na saida Digital D6

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon May 20 23:28:24 2019 +0000
+++ b/main.cpp	Mon May 20 20:59:29 2019 -0300
@@ -1,10 +1,15 @@
 #include "mbed.h"
+#include "Grove_temperature.h"
 
-DigitalOut led1 (LED1);
+DigitalOut led1 (LED1);         // LED 1 de 3 DO BOARD
+DigitalOut led_dig(D6);         // LED 1 da porta Digital 6 (A placa tem D6 e D8)
 
-int main () {
+Grove_temperature temp(A1);     // Deve ser ligado na Porta ANALOGICA 1 
+Serial pc(USBTX, USBRX);        // SAIDA SERIAL PADRÃO
+
+void rodarLed() {
     int count = 0;
-    while(count ++ < 10){
+    while(count ++ < 10) {
         led1 = 1;
         wait(0.4);
         led1 = 0;
@@ -12,30 +17,32 @@
     }
 
     led1 = 0;
-    return 1;
+}
+
+void buss_ligth() {
+    led_dig = 1;
+    wait(0.3);
+    led_dig = 0;    
 }
 
-/** 
-#include "mbed.h"
-#include "Grove_temperature.h"
-
-DigitalOut led(D6);
-Grove_temperature temp(A1);
-Serial pc(USBTX, USBRX);
+int main () {
+    printf("!!!INICIO!!!\r\n");
 
-// main() runs in its own thread in the OS
-int main() {
-    printf("!!!INICIO!!!\r\n");
-    pc.baud(9600);
-    while (true) {
-        printf("temperature = %2.2f\r\n", temp.getTemperature());
+    int count = 0;
+    float tempValue = 0;
+    while(count ++ < 50) {
+        tempValue = temp.getTemperature();
+        printf("%2d -> Temperature = %2.2f\r\n", count, tempValue);
         
-        led = 1;    // Switch ON the LED.
-        wait(0.5);  // Wait for 0.5 Seconds.
-        led = 0;    // Switch OFF the LED.
-        wait(0.5);  // Wait for 0.5 Seconds.
-        
+        // Acende o LED quando está acima do valor indicado !!
+        if(tempValue > 30.0) {
+            led_dig = 1;
+        } else {
+            led_dig = 0;
+        }
         wait(1);
     }
+
+    printf("!!!FIM DE LEITURA!!!\r\n");
+    return 1;
 }
-*/