ejemplo taller prepa tec
Dependencies: MMA8451Q Servo mbed
Diff: main.cpp
- Revision:
- 3:c8e9a933acd2
- Parent:
- 2:d07fe9f3d109
diff -r d07fe9f3d109 -r c8e9a933acd2 main.cpp --- a/main.cpp Fri Feb 26 16:15:53 2016 +0000 +++ b/main.cpp Fri Feb 26 16:22:10 2016 +0000 @@ -6,16 +6,16 @@ #if defined (TARGET_KL25Z) || defined (TARGET_KL46Z) - PinName const SDA = PTE25; - PinName const SCL = PTE24; +PinName const SDA = PTE25; +PinName const SCL = PTE24; #elif defined (TARGET_KL05Z) - PinName const SDA = PTB4; - PinName const SCL = PTB3; +PinName const SDA = PTB4; +PinName const SCL = PTB3; #elif defined (TARGET_K20D50M) - PinName const SDA = PTB1; - PinName const SCL = PTB0; +PinName const SDA = PTB1; +PinName const SCL = PTB0; #else - #error TARGET NOT DEFINED +#error TARGET NOT DEFINED #endif #define MMA8451_I2C_ADDRESS (0x1d<<1) @@ -36,7 +36,7 @@ { float TSILec; float x, y, z; - MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); + MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); PwmOut red(LED_RED); PwmOut green(LED_GREEN); PwmOut blue(LED_BLUE); @@ -45,7 +45,7 @@ while (true) { //Check Touch Press - if(tsi.readPercentage()>0.001) { + if(tsi.readPercentage()>0.01) { TSILec=tsi.readPercentage(); if(TSILec<0.25) { red=1; @@ -69,9 +69,9 @@ } Motor1=TSILec; //Assign touch read to motor wait(0.1); - } - //Read Accel - else{ + } + //Read Accel + else { x=acc.getAccX(); y=acc.getAccY(); z=acc.getAccZ();