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.
Diff: main.cpp
- Revision:
- 9:331dbf3b341d
- Parent:
- 8:c64f76d4deff
- Child:
- 10:7bdbc8eb0d69
--- a/main.cpp Sat Jan 10 03:46:30 2015 +0000 +++ b/main.cpp Sat Jan 10 04:10:47 2015 +0000 @@ -32,27 +32,34 @@ //int itg3200_Data[3]; //int hmc5843_Data[3]; -DigitalOut myled(LED1); +PwmOut led(LED1); + +float brightness = 0.0; int main() { - char cmd[2]; + //char cmd[2]; //init_adxl345(); //init_hmc5843(); //init_itg3200(); + pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down.\n"); + while(1) { - cmd[0] = 0x01; - cmd[1] = 0x00; + //cmd[0] = 0x01; + //cmd[1] = 0x00; //i2c.write(addr, cmd, 2); // i2c.write(address, command, bytes); - pc.printf("Hello."); + char c = pc.getc(); + if((c == 'u') && (brightness < 0.5)) { + brightness += 0.01; + led = brightness; + } + if((c == 'd') && (brightness > 0.0)) { + brightness -= 0.01; + led = brightness; + } - myled = 1; - wait(0.1333); - myled = 0; - wait(1.9); - //this is an awesome program. } }