Sagawa Electronics,inc.

Dependencies:   mbed

Fork of sagawa_lpc1114 by kazushiro tanimoto

main.cpp

Committer:
zero515
Date:
2016-11-26
Revision:
1:dbde3f68f80d
Parent:
0:d90f3421aaef
Child:
2:de000dc1b277

File content as of revision 1:dbde3f68f80d:

/* 
 * Copyright (c) 2012-2016 Sagawa Electronics,inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#include "mbed.h"
#include "TB6612.h"
#include "SoftPWM.h"

DigitalOut led1(P2_11);
DigitalOut led2(P0_2);
DigitalOut led3(P0_7);
DigitalOut led4(P0_3);

AnalogIn ad0(P0_11);
AnalogIn ad1(P1_0);
AnalogIn ad2(P1_1);
AnalogIn ad3(P1_2);
AnalogIn ad5(P1_4);
AnalogIn ad7(P1_11);

TB6612 motor1a(P2_7,P2_9,P2_8);
TB6612 motor1b(P2_4,P2_6,P2_5);

Serial pc(P1_7, P1_6);


int main() {
    pc.baud(19200);
    
    led1 = 0;
    led2 = 0;
    led3 = 0;
    led4 = 0;
    motor1a = 0.0;
    motor1b = 0.0;
    
    while(1) {
        
        led1 = 1;
        motor1a = 0.2;    // Motor forward.
        wait(1.0);
        led1 = 0;
        
        led2 = 1;
        motor1a = -0.2;   // Motor reversal.
        wait(1.0);
        led2 = 0;

        motor1a = 0.0;
        
        led3 = 1;
        motor1b = 0.2;    // Motor forward.
        wait(1.0);
        led3 = 0;
        
        led4 = 1;
        motor1b = -0.2;   // Motor reversal.
        wait(1.0);
        led4 = 0;
        
        motor1b = 0.0;
        
        pc.printf("check_ok \r\n");
    }
}