
Contador de pasos
main.cpp@9:ff57931068f4, 2016-02-12 (annotated)
- Committer:
- OlySolano
- Date:
- Fri Feb 12 13:57:04 2016 +0000
- Revision:
- 9:ff57931068f4
- Parent:
- 1:aa7e037498b3
- Child:
- 10:5b9057acf106
actulizacion
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OlySolano | 0:df404584fbad | 1 | #include "mbed.h" |
OlySolano | 0:df404584fbad | 2 | #include "MMA8451Q.h" |
OlySolano | 0:df404584fbad | 3 | |
OlySolano | 9:ff57931068f4 | 4 | Serial pc (USBTX, USBRX); |
OlySolano | 9:ff57931068f4 | 5 | MMA8451Q acc(PTE25, PTE24); |
OlySolano | 9:ff57931068f4 | 6 | PwmOut rled(LED_RED); |
OlySolano | 9:ff57931068f4 | 7 | PwmOut gled(LED_GREEN); |
OlySolano | 9:ff57931068f4 | 8 | PwmOut bled(LED_BLUE); |
OlySolano | 9:ff57931068f4 | 9 | int16_t data [3]; |
OlySolano | 9:ff57931068f4 | 10 | int cont,z; |
OlySolano | 0:df404584fbad | 11 | |
OlySolano | 0:df404584fbad | 12 | int main() { |
OlySolano | 9:ff57931068f4 | 13 | pc.baud(9600); |
OlySolano | 9:ff57931068f4 | 14 | pc.format(8,SerialBase::None,1); |
OlySolano | 9:ff57931068f4 | 15 | pc.putc(65); |
OlySolano | 9:ff57931068f4 | 16 | |
OlySolano | 0:df404584fbad | 17 | while(1) { |
OlySolano | 9:ff57931068f4 | 18 | acc.getAccAllAxis(data); |
OlySolano | 1:aa7e037498b3 | 19 | |
OlySolano | 9:ff57931068f4 | 20 | // serial1.printf("%d\n",data[0]); |
OlySolano | 9:ff57931068f4 | 21 | // serial1.printf("%d\n",data[1]); |
OlySolano | 9:ff57931068f4 | 22 | pc.printf("%d\n",data[2]); |
OlySolano | 1:aa7e037498b3 | 23 | |
OlySolano | 9:ff57931068f4 | 24 | // rled = 1.0 - abs(data[0]/17000.0); |
OlySolano | 9:ff57931068f4 | 25 | // gled = 1.0 - abs(data[1]/17000.0); |
OlySolano | 9:ff57931068f4 | 26 | z=bled = 1.0 - abs(data[2]/17000.0); |
OlySolano | 1:aa7e037498b3 | 27 | wait(0.4); |
OlySolano | 9:ff57931068f4 | 28 | |
OlySolano | 9:ff57931068f4 | 29 | |
OlySolano | 9:ff57931068f4 | 30 | }} |