Controlling a Grove LED bar (D5) with a Grove button (A0).
Diff: main.cpp
- Revision:
- 0:c7741b38fc0f
- Child:
- 1:38445b7f8db8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Aug 16 18:38:43 2016 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+#include "LED_Bar.h"
+
+LED_Bar bar(D6, D5);
+DigitalIn button(A0);
+
+int main() {
+ int j;
+ bar.setLevel(0);
+
+ while(1) {
+ wait(0.2);
+ if (button) {
+ bar.setLevel(j++);
+ } else {
+ bar.setLevel(j);
+ }
+ if (j == 11) {
+ bar.setLevel(0);
+ j = 0;
+ }
+ }
+}
Jenny Plunkett