Mark Schwarzer / Mbed 2 deprecated Schwarzer_A5_1_Temperature

Dependencies:   mbed

main.cpp

Committer:
markschwarzer
Date:
2020-10-16
Revision:
6:4b366905136f
Parent:
5:265e04e0cc1d

File content as of revision 6:4b366905136f:

//Mark Schwarzer Assignment 5 part 1
#include "mbed.h"

Serial pc(USBTX, USBRX) ;
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
AnalogIn aI(p19);
DigitalIn switch_input(p17);
float T; //temp
float V;  //voltage
float m;  //variable in equation defined
float a;
float i;
float n;

int main() {
    V=(3.3); //Vref
    m=-1481.96;
    a=1.8639;
    i=3.88e-6;
    n=2.1962e6;

V=aI.read();
T=(m+(sqrt(n+(a-V)/(i)))); //Temp equation
pc.printf("V=%f\r\n", V );

while(1) {
    if (25>=T>20) {
        led1=1; //on
        pc.printf("T=%f\r\n", T ); }
    else if (30>=T>25) {
        led2=1; //on
        led1=0;
        pc.printf("T=%f\r\n", T ); }
    else if(T>30) {
        led3=1;  //on
        led2=0;
        led1=0;
        pc.printf("T=%f\r\n", T );  }      
}}

int second() {

//NOT SURE IF THIS IS CORRECT from here down, but it seems to compile.
//any help would be appreciated 

while(1) {
    if (switch_input==1) {
        pc.printf("%d\r\n", switch_input.read());
        wait(1); //1 Hz
        }
        else if (switch_input==.25) { //.25 Hz
             wait(4);
             pc.printf("%d\r\n", switch_input.read()); 
             }
        else if(switch_input==0) {
            pc.printf("%d\r\n", switch_input.read()); 
            wait(0); }} //off
            }