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
- Committer:
- markschwarzer
- Date:
- 2020-10-16
- Revision:
- 5:265e04e0cc1d
- Parent:
- 4:657329790c52
- Child:
- 6:4b366905136f
File content as of revision 5:265e04e0cc1d:
#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 }