Edgar Ochoa
/
ProyectoNivel
Proyecto Nivel, Edgar Ochoa, Erik Garcia
main.cpp@0:cf09f0ecb330, 2016-02-10 (annotated)
- Committer:
- verden32
- Date:
- Wed Feb 10 18:28:56 2016 +0000
- Revision:
- 0:cf09f0ecb330
- Child:
- 1:f15981c66b73
Proyecto Nivel Edgar Ochoa, Erik Garcia
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
verden32 | 0:cf09f0ecb330 | 1 | #include "mbed.h" |
verden32 | 0:cf09f0ecb330 | 2 | #include "MMA8451Q.h" |
verden32 | 0:cf09f0ecb330 | 3 | MMA8451Q acc(PTE25, PTE24); |
verden32 | 0:cf09f0ecb330 | 4 | PwmOut r(LED_RED); |
verden32 | 0:cf09f0ecb330 | 5 | PwmOut g(LED_GREEN); |
verden32 | 0:cf09f0ecb330 | 6 | PwmOut b(LED_BLUE); |
verden32 | 0:cf09f0ecb330 | 7 | |
verden32 | 0:cf09f0ecb330 | 8 | Serial pc(USBTX,USBRX); |
verden32 | 0:cf09f0ecb330 | 9 | int16_t data[3]; |
verden32 | 0:cf09f0ecb330 | 10 | int main() { |
verden32 | 0:cf09f0ecb330 | 11 | |
verden32 | 0:cf09f0ecb330 | 12 | pc.baud(9600); //velocidad serial// |
verden32 | 0:cf09f0ecb330 | 13 | pc.format(8,SerialBase::None ,1) ; |
verden32 | 0:cf09f0ecb330 | 14 | pc.putc(65); |
verden32 | 0:cf09f0ecb330 | 15 | |
verden32 | 0:cf09f0ecb330 | 16 | while(1) { |
verden32 | 0:cf09f0ecb330 | 17 | |
verden32 | 0:cf09f0ecb330 | 18 | acc.getAccAllAxis(data); |
verden32 | 0:cf09f0ecb330 | 19 | |
verden32 | 0:cf09f0ecb330 | 20 | r = 1.0 - abs(data[0]/16500.0); |
verden32 | 0:cf09f0ecb330 | 21 | g = 1.0 - abs(data[1]/16500.0); |
verden32 | 0:cf09f0ecb330 | 22 | b = 1.0 - abs(data[2]/16500.0); |
verden32 | 0:cf09f0ecb330 | 23 | |
verden32 | 0:cf09f0ecb330 | 24 | |
verden32 | 0:cf09f0ecb330 | 25 | pc.printf("%d,%d,%d,\n",data[0],data[1],data[2]); |
verden32 | 0:cf09f0ecb330 | 26 | |
verden32 | 0:cf09f0ecb330 | 27 | wait(0.4); |
verden32 | 0:cf09f0ecb330 | 28 | |
verden32 | 0:cf09f0ecb330 | 29 | } |
verden32 | 0:cf09f0ecb330 | 30 | |
verden32 | 0:cf09f0ecb330 | 31 | } |
verden32 | 0:cf09f0ecb330 | 32 |