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.
Fork of PRO2_samlet_kode by
main.cpp
- Committer:
- OlgaHoeyer
- Date:
- 2017-05-19
- Revision:
- 2:0864be57f81e
- Parent:
- 1:135bd458e39e
- Child:
- 3:b6c7d01e1eb8
File content as of revision 2:0864be57f81e:
//Defining and Including stuff up here
#include "mbed.h"
#include "SHTx/sht15.hpp"
#include <7_segment_control.h>
#include <compare.h>
#include <data_out.h>
#include <logging.h>
#include <rgb_led.h>
#include <Ticker.h>
//Declaration of GLOBAL VARIABLES:
float temperature, humidity; //this will be data read from sensor
void GetTemperatureAndHumidity(); //via denne function
int temperature_low :=18;
int temperature_high :=22; //DELETE LATER!
Serial pc(USBTX, USBRX);
InterruptIn event(USER_BUTTON);
DigitalOut myled(LED1);
DigitalIn up(PA_5);
DigitalIn down(PA_6);
SHTx::SHT15 sensor(PB_8, PB_9); //ports on the Nucleo: PB_8, PB_9
Ticker tick1;
Ticker tick2;
Ticker tick3;
Ticker tick4;
int main()
{
while(1) {
logging ();
//tick1.atach(Settings(), 20); //MISSING PROGRAM PART!!!!!!!
tick2.atach(GetTemperatureAndHumidity(),20); //Data Collection
//tick3.atach(Compare_values(hum, temp, temperature_low, temperature_high),20); //Data Analysis
tick4.atach(rgb_outp(Compare_values(hum, temp, temperature_low, temperature_high)),20); //RGB_LED_output
return;
}
}
void GetTemperatureAndHumidity() //canøt move to the .h file, pga "sensor" definitions.
{
// Speed things up a bit.
sensor.setOTPReload(false);
sensor.setResolution(true);
busy = true;
sensor.update();
busy = false;
// Temperature in celcius
sensor.setScale(false);
temperature=sensor.getTemperature();
// Relative Humidity
humidity=sensor.getHumidity();
wait(5);
return;
}
