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.
Dependencies: MODSERIALhacked Convert SLCD mbed-src
main.cpp
- Committer:
- jhaugen
- Date:
- 2014-12-11
- Revision:
- 5:112df51d4815
- Parent:
- 4:9930547c1cfa
- Child:
- 6:3fbe44c7c26a
File content as of revision 5:112df51d4815:
#include "mbed.h"
#include "convert.h"
// false == on; true == off for the leds
DigitalOut myled(LED_GREEN);
DigitalOut redled(LED_RED);
Serial pc(USBTX, USBRX);
AnalogIn my_light_sensor(PTE22);
Ticker ticker;
int tick_count = 0;
void systick() {
if (tick_count % 10 == 0) {
redled = true;
}
else {
redled = false;
}
tick_count++;
}
int main()
{
ticker.attach_us(&systick, 100000);
pc.baud(115200);
int i = 0;
bool pulse_value = false;
pc.printf("Hello World!\n");
Convert lcd;
while (true) {
float let_there_be_light;
// set the pulse high for 100ms
pulse_value = true;
myled = pulse_value; // toggle a led
let_there_be_light = my_light_sensor.read();
pc.printf("%f \r\n", let_there_be_light);
lcd.display(1);
wait_ms(100.0f);
// set it low again for the remainder of the second
pulse_value = false;
myled = pulse_value; // toggle a led
let_there_be_light = my_light_sensor.read();
pc.printf("%f \r\n", let_there_be_light);
lcd.display(0);
wait_ms(900.0f);
/*
pc.printf("%d \n", i); // print the value of variable i
i++; // increment the variable
myled = pulsevalue; // toggle a led
*/
}
}
