うおーるぼっとをWiiリモコンでコントロールする新しいプログラムです。 以前のものより、Wiiリモコンが早く繋がる様になりました。 It is a program which controls A with the Wii remote. ※ A Bluetooth dongle and a Wii remote control are needed.

Dependencies:   USBHost mbed FATFileSystem mbed-rtos

Committer:
jksoft
Date:
Mon Jun 10 16:01:50 2013 +0000
Revision:
0:fccb789424fc
1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:fccb789424fc 1 /**
jksoft 0:fccb789424fc 2 * Motor Driver TB6612 Control Library
jksoft 0:fccb789424fc 3 *
jksoft 0:fccb789424fc 4 * -- TB6612 is a device of the TOSHIBA.
jksoft 0:fccb789424fc 5 *
jksoft 0:fccb789424fc 6 * Copyright (C) 2012 Junichi Katsu (JKSOFT)
jksoft 0:fccb789424fc 7 */
jksoft 0:fccb789424fc 8
jksoft 0:fccb789424fc 9
jksoft 0:fccb789424fc 10 #include "TB6612.h"
jksoft 0:fccb789424fc 11
jksoft 0:fccb789424fc 12 // TB6612 Class Constructor
jksoft 0:fccb789424fc 13 TB6612::TB6612(PinName pwm, PinName fwd, PinName rev):
jksoft 0:fccb789424fc 14 _pwm(pwm), _fwd(fwd), _rev(rev) {
jksoft 0:fccb789424fc 15
jksoft 0:fccb789424fc 16 _fwd = 0;
jksoft 0:fccb789424fc 17 _rev = 0;
jksoft 0:fccb789424fc 18 _pwm = 0.0;
jksoft 0:fccb789424fc 19 _pwm.period(0.001);
jksoft 0:fccb789424fc 20 }
jksoft 0:fccb789424fc 21
jksoft 0:fccb789424fc 22 // Speed Control
jksoft 0:fccb789424fc 23 // arg
jksoft 0:fccb789424fc 24 // int speed -100 -- 0 -- 100
jksoft 0:fccb789424fc 25 void TB6612::speed(int speed) {
jksoft 0:fccb789424fc 26
jksoft 0:fccb789424fc 27 if( speed > 0 )
jksoft 0:fccb789424fc 28 {
jksoft 0:fccb789424fc 29 _pwm = ((float)speed) / 100.0;
jksoft 0:fccb789424fc 30 _fwd = 1;
jksoft 0:fccb789424fc 31 _rev = 0;
jksoft 0:fccb789424fc 32 }
jksoft 0:fccb789424fc 33 else if( speed < 0 )
jksoft 0:fccb789424fc 34 {
jksoft 0:fccb789424fc 35 _pwm = -((float)speed) / 100.0;
jksoft 0:fccb789424fc 36 _fwd = 0;
jksoft 0:fccb789424fc 37 _rev = 1;
jksoft 0:fccb789424fc 38 }
jksoft 0:fccb789424fc 39 else
jksoft 0:fccb789424fc 40 {
jksoft 0:fccb789424fc 41 _fwd = 1;
jksoft 0:fccb789424fc 42 _rev = 1;
jksoft 0:fccb789424fc 43 }
jksoft 0:fccb789424fc 44 }
jksoft 0:fccb789424fc 45
jksoft 0:fccb789424fc 46
jksoft 0:fccb789424fc 47 // Speed Control with time-out
jksoft 0:fccb789424fc 48 // arg
jksoft 0:fccb789424fc 49 // int speed -100 -- 0 -- 100
jksoft 0:fccb789424fc 50 // int time 0
jksoft 0:fccb789424fc 51 void TB6612::move(int sspeed , int time)
jksoft 0:fccb789424fc 52 {
jksoft 0:fccb789424fc 53 speed(sspeed);
jksoft 0:fccb789424fc 54 wait_ms(time);
jksoft 0:fccb789424fc 55 }