4180 lab 1
Dependencies: mbed MCP23S17 PinDetect USBDevice
Revision 4:6a7029bf4e1c, committed 2020-01-15
- Comitter:
- emilywilson
- Date:
- Wed Jan 15 19:14:47 2020 +0000
- Parent:
- 3:d84f4a501915
- Child:
- 5:d1ad3a964858
- Commit message:
- part 3
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jan 15 18:38:18 2020 +0000
+++ b/main.cpp Wed Jan 15 19:14:47 2020 +0000
@@ -3,17 +3,17 @@
#include "PinDetect.h"
DigitalOut myled(p26);
-DigitalOut builtinLED(LED1);
+PwmOut builtinLED(LED1);
DigitalIn pb(p22);
//DigitalIn pb2(p21);
// p10 is most significant bit
-//BusIn ledSelect(p8, p9, p10);
-//
-//PinName redPin = p11;
-//PinName greenPin = p12;
-//PinName bluePin = p13;
-//
+BusIn ledSelect(p18, p19, p20);
+
+PinName redPin = p24;
+PinName greenPin = p25;
+PinName bluePin = p23;
+
PinDetect pb1(p21);
PinDetect pb2(p22);
@@ -32,44 +32,40 @@
}
int main() {
+
+ pb1.mode(PullUp);
+ pb2.mode(PullUp);
+ wait(0.1);
+
+ pb1.attach_asserted(&pb1_hit_callback);
+ pb2.attach_asserted(&pb2_hit_callback);
+ pb1.setSampleFrequency();
+ pb2.setSampleFrequency();
+
while(1) {
// Part 1
// myled = !pb;
// Part 2
- pb1.mode(PullUp);
- pb2.mode(PullUp);
- wait(0.1);
-
- builtinLED = p;
+// builtinLED = p;
+// wait(0.5);
// Part 3
-// RGBLed myRBGLed = RGBLed(redPin, greenPin, bluePin);
-// float redVal = 0.0f;
-// float greenVal = 0.0f;
-// float blueVal = 0.0f;
-//
-// pb1.mode(PullUp)
-// pb2.mode(PullUp)
-// wait(0.1)
-//
-// // Possibly try attach_asserted
-// pb1.attach_deasserted(&pb1_hit_callback);
-// pb2.attach_deasserted(&pb2_hit_callback);
-// pb1.setSampleFrequency();
-// pb2.setSampleFrequency();
-//
-// if (ledSelect & 0x1) {
-// redVal = 1.0 * p;
-// }
-// if (ledSelect & 0x2) {
-// greenVal = 1.0 * p;
-// }
-// if (ledselect & 0x4) {
-// blueVal = 1.0 * p;
-// }
-// }
+ RGBLed myRBGLed = RGBLed(redPin, greenPin, bluePin);
+ float redVal = 0.0f;
+ float greenVal = 0.0f;
+ float blueVal = 0.0f;
+
+ if (ledSelect & 0x1) {
+ redVal = 1.0 * p;
+ }
+ if (ledSelect & 0x2) {
+ greenVal = 1.0 * p;
+ }
+ if (ledSelect & 0x4) {
+ blueVal = 1.0 * p;
+ }
- // Part 4
+ // Part 4
}
}