Proyecto escolar

Dependencies:   mbed FXOS8700Q TextLCD

Files at this revision

API Documentation at this revision

Comitter:
thesad
Date:
Thu Jun 04 20:13:34 2020 +0000
Commit message:
Practica 7;

Changed in this revision

FXOS8700Q.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r c64c42c6b39b FXOS8700Q.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXOS8700Q.lib	Thu Jun 04 20:13:34 2020 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Freescale/code/FXOS8700Q/#aee7dea904e2
diff -r 000000000000 -r c64c42c6b39b TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Thu Jun 04 20:13:34 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r c64c42c6b39b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jun 04 20:13:34 2020 +0000
@@ -0,0 +1,128 @@
+#include "mbed.h"
+#include "C12832.h"
+#include "Sht31.h"
+
+C12832 lcd(SPI_MOSI, SPI_SCK, SPI_MISO, p8, p11);
+
+PwmOut speaker(p21);
+AnalogIn pot(p15);
+DigitalOut L1(p5);
+DigitalIn bt(p20);
+Sht31 sht31(I2C_SDA, I2C_SCL);
+
+void play_tone(float frequency, float volume, float interval, float rest) {
+    speaker.period(1.0 / frequency);
+    speaker = volume;
+    wait(interval);
+    speaker = 0.0;
+    wait(rest);
+}
+
+int main() {
+  printf("Práctica 7, equipo 3\n");
+ 
+ int i, s;
+ float x;
+      x = pot.read();
+  s = 5;
+
+ lcd.cls();
+   for(int x = 0; x < 0.4; ){
+     
+     lcd.locate(1,1);
+     lcd.printf("Precalentando");
+     lcd.copy_to_lcd();
+     wait(0.5);
+     lcd.cls();
+     
+     wait(1);
+     lcd.locate(1,1);
+     lcd.printf("Precalentando");
+     lcd.copy_to_lcd();
+     wait(0.5);
+     lcd.cls();
+     
+     wait(1);
+     lcd.locate(1,1);
+     lcd.printf("Precalentando");
+     lcd.copy_to_lcd();
+     wait(0.5);
+     lcd.cls();
+     
+     wait(1);
+     lcd.locate(1,1);
+     lcd.printf("Precalentando");
+     lcd.copy_to_lcd();
+     wait(0.5);
+     lcd.cls();
+     
+     wait(1);
+     lcd.cls();
+     lcd.locate(1,1);
+     lcd.printf("Precalentando");
+     lcd.copy_to_lcd();
+     }
+  
+  
+ while(1){
+     
+     if(bt == 1){
+     
+     x = pot.read();
+     lcd.cls();
+     
+ for(x = .25; x < .35 ;  ){
+     lcd.cls();
+     lcd.printf("Niveles de C02 normales");
+     lcd.copy_to_lcd();
+     play_tone(450.0, 0.5, 1, 1.5);}
+ for(x = .350; x < 1; ){
+          lcd.cls();
+     lcd.printf("Congestionado, pero con buen intercambio de aire.");
+     lcd.copy_to_lcd();
+     play_tone(460.0, 0.5, 1, 1);}
+     
+ for(x = 1; x < 2; ){
+          lcd.cls();
+     lcd.printf("Calidad de aire baja");
+     lcd.copy_to_lcd();
+     play_tone(470.0, 0.5, 1, 0.7);}
+     
+ for(x = 2; x < 5; ){
+          lcd.cls();
+     lcd.printf("Peligro");
+     lcd.copy_to_lcd();
+     play_tone(480.0, 0.5, 0.7, 0.5);}
+     
+ if(x == 5){
+    L1 = 1;
+          lcd.cls();
+     lcd.printf("¡Aléjate!");
+     lcd.copy_to_lcd();
+     play_tone(500.0, 0.5, 0.5, 0.1);}
+     
+ if(x == 0){
+     lcd.cls();
+     lcd.printf("Error");
+     lcd.copy_to_lcd();}
+            
+                        }
+    else{
+           printf("Si el led enciende, significa peligro");
+           lcd.cls();
+
+        float temp = sht31.readTemperature();
+        float humidity = sht31.readHumidity();
+
+        lcd.locate(3, 3);
+        lcd.printf("Temperature: %.2f C", temp);
+        lcd.locate(3, 13);
+        lcd.printf("Humidity: %.2f %%", humidity);
+
+        L1 = temp > 40.0f;
+
+        wait(0.5f);
+        }
+
+        }
+}
\ No newline at end of file
diff -r 000000000000 -r c64c42c6b39b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jun 04 20:13:34 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file