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:
- 3:b755f0cf35bc
- Parent:
- 2:e6e11d6db1dc
- Child:
- 4:657329790c52
File content as of revision 3:b755f0cf35bc:
#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;
float V;
int main() {
V=aI.read_u16();
T = -1481.96+ sqrt((2.1962e6)+((1.8639-V)/3.88e-6)));
pc.printf("V=%f\r\n", V );
while(1) {
if (25>=T>20) {
led1=1;
pc.printf("T=%d\r\n", T ); }
else if (30>=T>25) {
led2=1;
led1=0;
pc.printf("T=%d\r\n", T ); }
else (T>30) {
led3=1;
led2=0;
led1=0;
pc.printf("T=%d\r\n", T ); }
}}
int second() {
while(1) {
if (switch_input==1) {
pc.printf("%d\r\n", switch_input.read());
wait(1); //1 Hz
}
else if (wait(4)) { //.25 Hz
pc.printf("%d\r\n", switch_input.read());
}
else (switch_input==0) {
pc.printf("%d\r\n", switch_input.read());
wait(0) }} //off
}