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:
- 0:ea651607da73
- Child:
- 8:db9bcb92ff2a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Sep 02 20:15:47 2022 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+#include "PinDetect.h"
+
+DigitalOut red(p5);
+PwmOut led(LED1);
+DigitalIn pblight(p8);
+PinDetect pbdim(p7);
+PinDetect pbbright(p6);
+float volatile brightness = 0.5f;
+void pbdim_hit_callback (void) {
+ if(1.0f > brightness ||brightness >= 0.0f) {
+ brightness+= 0.1f;
+ }
+}
+void pbbright_hit_callback (void) {
+ if (0.0f < brightness || brightness <= 1.0f) {
+ brightness -= 0.1f;
+ }
+}
+int main() {
+ pblight.mode(PullUp);
+ pbdim.mode(PullUp);
+ pbbright.mode(PullUp);
+ wait(0.001);
+
+ pbdim.attach_deasserted(&pbdim_hit_callback);
+ pbdim.setSampleFrequency();
+ pbbright.attach_deasserted(&pbbright_hit_callback);
+ pbbright.setSampleFrequency();
+ while(1) {
+ red = !pblight;
+ led = brightness;
+ wait(.5);
+ }
+}
+