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: DebounceIn mbed PinDetect
Diff: JessesLab1/main.cpp
- Revision:
- 42:841b1bf3f173
- Parent:
- 41:5bcf3ab83113
- Child:
- 43:a07c473ee4c7
diff -r 5bcf3ab83113 -r 841b1bf3f173 JessesLab1/main.cpp
--- a/JessesLab1/main.cpp Mon Jan 18 03:40:13 2016 +0000
+++ b/JessesLab1/main.cpp Mon Jan 18 10:00:29 2016 -0500
@@ -3,16 +3,38 @@
#include "DebounceIn.h"
#include "PinDetect.h"
-PinDetect pb(p8);
-DigitalOut led(p21);
+PinDetect light(p8);
+DebounceIn dimmer(p15);
+PwmOut led(p21);
int main() {
+float ind = 0;
+float bright = 0;
+
pb.mode(PullUp);
while(1) {
- led = !pb;
+ if(!dimmer) {
+ ind = ind + 1;
+ wait(1);
+ if(ind <= 4) {
+ ind = 0;
+ }
+ }
+
+ bright = ind * 0.25;
+
+ if(!light) {
+
+ led.write(bright);
+
+ }
+ else {
+ led.write(0);
+ }
+ //led = !pb;
}
}