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:
- sjoerdbarts
- Date:
- 2016-09-26
- Revision:
- 0:1883abafaa19
- Child:
- 1:3011d69df4a9
File content as of revision 0:1883abafaa19:
#include "mbed.h"
#define SERIAL_BAUD 115200 // baud rate for serial communication
// Homework set 1, excersize 9
// Serial connection with PC
Serial pc(USBTX,USBRX);
AnalogIn pot(A0);
DigitalOut led(D7);
const float kTimeReadToggle = 0.5f;
volatile float potvalue=0.0;
void readanalog(){
printf("AnalogOut: %f \n\r", potvalue);
}
int main()
{
// Set baud connection with PC
pc.baud(SERIAL_BAUD);
pc.printf("\r\n ***THERMONUCLEAR WARFARE COMMENCES*** \r\n");
Ticker tick_toggle_read;
tick_toggle_read.attach(readanalog,kTimeReadToggle);
while(true){
potvalue = pot.read();
if(pot > 0.3f){
led=1;
} else {
led=0;
}
}
}