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:
- ygendrault
- Date:
- 2017-12-15
- Revision:
- 0:fe8a2e63737f
File content as of revision 0:fe8a2e63737f:
#include "mbed.h"
Serial pc(SERIAL_TX, SERIAL_RX);
DigitalOut led(LED1);
int test = 0;
char previous = 0;
int main()
{
pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n");
while(1) {
char c = pc.getc(); // Read hyperterminal
if (c == '0') {
if (previous=='1')
{
test =0;
}
if (test==0)
{
test=1;
previous = '0';
led = 0; // OFF
}
else
{
pc.printf("LED already OFF\n");
}
}
if (c == '1') {
if (previous=='0')
{
test =0;
}
if (test==0)
{
test=1;
previous = '1';
led = 1; // OFF
}
else
{
pc.printf("LED already ON\n");
}
}
}
}