![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
キャタピラ用
Dependencies: 2342L012CR HCSR04 L6470 test_test MMA8451Q TSI mbed
Diff: main.cpp
- Revision:
- 0:049054ab53f0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 02 05:01:36 2013 +0000 @@ -0,0 +1,117 @@ +//DC_Moter +//2013.11.02 +//Ver 0.0.001 +//m.saito + +#include "mbed.h" +#include "TSISensor.h" + +int main() { + PwmOut M1IN1(PTD4); + PwmOut M1IN2(PTA12); + PwmOut M2IN1(PTA4); + PwmOut M2IN2(PTA5); + TSISensor tsi; + + while(1){ + M1IN1 = 0; + M1IN2 = 0; + M2IN1 = 1.0; + M2IN2 = 0; + } +} + + + + +/* +//step_Moter +//2013.10.19 +//Ver 0.0.001 +//m.saito + +#include "mbed.h" +#include "L6470.h" + +//Serial pc(USBTX, USBRX); +L6470 step1(PTD2, PTD3, PTD1,PTC0); // mosi, miso, sclk +//L6470 step2(p5, p6, p7,p11); // mosi, miso, sclk + + +int main() +{ + step1.Resets(); + //step2.Resets(); + + step1.Run(1,0x800); + //step2.Run(1,0x800); + + + wait_us(1); +} +*/ + + + + +/* + + +//DC_Moter(G-sensor,touchpad) +//Ultrasonic +//2013.10.12 +//Ver 0.0.001 +//m.saito + +#include "mbed.h" +#include "TSISensor.h" +#include "MMA8451Q.h" +#include "LCD.h" +#include "HCSR04.h" + +#define MMA8451_I2C_ADDRESS (0x1d<<1) + +int main(void) { + +//class-object + HCSR04 sensor(PTC10, PTC11); //Ultrasonic + LCD lcd(PTE0,PTE1); //LCD + MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); //G-sensor + PwmOut mtr(PTA12); //cw-only + TSISensor tsi; //touchpad-sensor + +//variable + float g = 0; //G-sensor + char g_str[20]; + float tp=0; //touchpad + char tp_str[20]; + long length; //Ultrasonic-length + char lg_str[20]; + + mtr = 1; //Duty Ratio + + while (1) + { + g = acc.getAccX()*90; //kakudo hyouji + tp = tsi.readPercentage(); + mtr = (tsi.readPercentage()==0)?(1-abs(acc.getAccX())):tp; + wait(0.1); + + length = sensor.distance(1); //cm-hyouji + + lcd.cls(); + lcd.locate(0,0); + sprintf (g_str,"%+5.1f",g); + lcd.printf("%s%s",g_str,"do"); + lcd.locate(0,1); + sprintf (tp_str,"%+5.3f",tp); + lcd.printf("%s%s",tp_str,"tp"); + wait (0.5); + lcd.cls(); + sprintf (lg_str,"%5d",length); + lcd.printf("%s%s",lg_str,"cm"); + wait (0.5); + } +} + +*/ \ No newline at end of file