Erik García
/
iluminacion
control iluminacion
main.cpp@1:0292d339c0ba, 2016-02-19 (annotated)
- Committer:
- through
- Date:
- Fri Feb 19 14:42:34 2016 +0000
- Revision:
- 1:0292d339c0ba
- Parent:
- 0:985d8bf2626d
iluminacion 2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
through | 0:985d8bf2626d | 1 | #include "mbed.h" |
through | 1:0292d339c0ba | 2 | Serial bt (PTE22, PTE23); |
through | 1:0292d339c0ba | 3 | Serial pc(USBTX,USBRX); |
through | 0:985d8bf2626d | 4 | PwmOut out(D3); |
through | 1:0292d339c0ba | 5 | AnalogIn pot(A0); |
through | 1:0292d339c0ba | 6 | int x=0; |
through | 0:985d8bf2626d | 7 | |
through | 0:985d8bf2626d | 8 | int main() { |
through | 0:985d8bf2626d | 9 | |
through | 0:985d8bf2626d | 10 | |
through | 0:985d8bf2626d | 11 | while(1) { |
through | 0:985d8bf2626d | 12 | |
through | 1:0292d339c0ba | 13 | if(bt.readable()){ |
through | 1:0292d339c0ba | 14 | x=bt.getc(); |
through | 1:0292d339c0ba | 15 | //bt.scanf("%c",&x); |
through | 1:0292d339c0ba | 16 | //wait(0.2); |
through | 1:0292d339c0ba | 17 | //pc.printf("%c\n",x); |
through | 1:0292d339c0ba | 18 | |
through | 1:0292d339c0ba | 19 | |
through | 1:0292d339c0ba | 20 | if(x=='1'){ |
through | 1:0292d339c0ba | 21 | out=0.3; |
through | 1:0292d339c0ba | 22 | } |
through | 1:0292d339c0ba | 23 | if(x=='2'){ |
through | 1:0292d339c0ba | 24 | out=0.6; |
through | 1:0292d339c0ba | 25 | } |
through | 1:0292d339c0ba | 26 | if(x=='3'){ |
through | 1:0292d339c0ba | 27 | out=1; |
through | 1:0292d339c0ba | 28 | } |
through | 1:0292d339c0ba | 29 | if(x=='0'){ |
through | 1:0292d339c0ba | 30 | out=0; |
through | 1:0292d339c0ba | 31 | } |
through | 1:0292d339c0ba | 32 | } |
through | 1:0292d339c0ba | 33 | |
through | 0:985d8bf2626d | 34 | wait(0.1); |
through | 0:985d8bf2626d | 35 | |
through | 0:985d8bf2626d | 36 | } |
through | 0:985d8bf2626d | 37 | } |
through | 0:985d8bf2626d | 38 |