Keith Stokely
/
CP4_LDM_Test_Blue
Blue LDM test for CP4
main.cpp@0:c57b9d018b9f, 2018-12-12 (annotated)
- Committer:
- kstokely
- Date:
- Wed Dec 12 15:13:50 2018 +0000
- Revision:
- 0:c57b9d018b9f
- Child:
- 1:5c0202cb8e6d
Update Before Analog Out;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kstokely | 0:c57b9d018b9f | 1 | #include "mbed.h" |
kstokely | 0:c57b9d018b9f | 2 | |
kstokely | 0:c57b9d018b9f | 3 | Serial pc(USBTX, USBRX); // tx, rx |
kstokely | 0:c57b9d018b9f | 4 | PwmOut led1(p23); |
kstokely | 0:c57b9d018b9f | 5 | PwmOut led2(p24); |
kstokely | 0:c57b9d018b9f | 6 | PwmOut led3(p25); |
kstokely | 0:c57b9d018b9f | 7 | |
kstokely | 0:c57b9d018b9f | 8 | float brightness = 1.0; |
kstokely | 0:c57b9d018b9f | 9 | |
kstokely | 0:c57b9d018b9f | 10 | int main() { |
kstokely | 0:c57b9d018b9f | 11 | pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\n"); |
kstokely | 0:c57b9d018b9f | 12 | |
kstokely | 0:c57b9d018b9f | 13 | while(1) { |
kstokely | 0:c57b9d018b9f | 14 | char c = pc.getc(); |
kstokely | 0:c57b9d018b9f | 15 | if((c == 'u') && (brightness < 1.0)) { |
kstokely | 0:c57b9d018b9f | 16 | brightness += 0.01; |
kstokely | 0:c57b9d018b9f | 17 | led1 = brightness; |
kstokely | 0:c57b9d018b9f | 18 | led2 = brightness; |
kstokely | 0:c57b9d018b9f | 19 | led3 = brightness; |
kstokely | 0:c57b9d018b9f | 20 | } |
kstokely | 0:c57b9d018b9f | 21 | if((c == 'd') && (brightness > 0.0)) { |
kstokely | 0:c57b9d018b9f | 22 | brightness -= 0.01; |
kstokely | 0:c57b9d018b9f | 23 | led1 = brightness; |
kstokely | 0:c57b9d018b9f | 24 | led2 = brightness; |
kstokely | 0:c57b9d018b9f | 25 | led3 = brightness; |
kstokely | 0:c57b9d018b9f | 26 | } |
kstokely | 0:c57b9d018b9f | 27 | |
kstokely | 0:c57b9d018b9f | 28 | } |
kstokely | 0:c57b9d018b9f | 29 | } |