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.
main.cpp
00001 #include "mbed.h" 00002 #include "Sht31.h" 00003 00004 DigitalOut led1(LED1); 00005 00006 //sda, scl 00007 Sht31 temp_sensor(I2C_SDA, I2C_SCL); 00008 00009 00010 Thread thread, thread1; 00011 00012 bool alarm = false; 00013 int extreme_humidity = 40; 00014 00015 void blink() 00016 { 00017 while (true) 00018 { 00019 led1 = !led1; 00020 wait_ms (alarm ? 100 : 1000); 00021 } 00022 } 00023 00024 void sensor_thread() 00025 { 00026 float h; 00027 while (true) { 00028 h = temp_sensor.readHumidity(); 00029 printf(" %f\n\r", h); 00030 wait_ms (1000); 00031 if (h >= extreme_humidity) 00032 { 00033 printf("ALARM ALARM ALARM \n\r"); 00034 alarm = true; 00035 } 00036 else 00037 { 00038 alarm = false; 00039 } 00040 } 00041 } 00042 00043 int main() 00044 { 00045 thread.start(sensor_thread); 00046 thread1.start(blink); 00047 }
Generated on Mon Aug 1 2022 18:19:15 by
1.7.2