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.
Revision 0:19aacd50bf59, committed 2016-09-26
- Comitter:
- Jankoekenpan
- Date:
- Mon Sep 26 09:46:00 2016 +0000
- Commit message:
- led brightness using buttons
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Sep 26 09:46:00 2016 +0000
@@ -0,0 +1,25 @@
+#include "mbed.h"
+
+PwmOut led(D3);
+
+InterruptIn but1(D5);
+InterruptIn but2(D4);
+
+volatile float brightness = 0.0f;
+
+void increaseBrightness() {
+ brightness = brightness + 0.1f > 1.0f ? 1.0f : brightness + 0.1f;
+ led.write(brightness);
+}
+
+void decreaseBrightness() {
+ brightness = brightness - 0.1f < 0.0f ? 0.0f : brightness - 0.1f;
+ led.write(brightness);
+}
+
+int main()
+{
+ but1.fall(increaseBrightness);
+ but2.fall(decreaseBrightness);
+ while (true);
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Sep 26 09:46:00 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85 \ No newline at end of file