Sagawa Electronics,inc.

Dependencies:   mbed

Fork of sagawa_lpc1114 by kazushiro tanimoto

Committer:
zero515
Date:
Sat Nov 26 19:09:24 2016 +0000
Revision:
1:dbde3f68f80d
Parent:
0:d90f3421aaef
Child:
2:de000dc1b277
up

Who changed what in which revision?

UserRevisionLine numberNew contents of line
zero515 1:dbde3f68f80d 1 /*
zero515 1:dbde3f68f80d 2 * Copyright (c) 2012-2016 Sagawa Electronics,inc.
zero515 1:dbde3f68f80d 3 *
zero515 1:dbde3f68f80d 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
zero515 1:dbde3f68f80d 5 * of this software and associated documentation files (the "Software"), to deal
zero515 1:dbde3f68f80d 6 * in the Software without restriction, including without limitation the rights
zero515 1:dbde3f68f80d 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
zero515 1:dbde3f68f80d 8 * copies of the Software, and to permit persons to whom the Software is
zero515 1:dbde3f68f80d 9 * furnished to do so, subject to the following conditions:
zero515 1:dbde3f68f80d 10 *
zero515 1:dbde3f68f80d 11 * The above copyright notice and this permission notice shall be included in
zero515 1:dbde3f68f80d 12 * all copies or substantial portions of the Software.
zero515 1:dbde3f68f80d 13 *
zero515 1:dbde3f68f80d 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
zero515 1:dbde3f68f80d 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
zero515 1:dbde3f68f80d 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
zero515 1:dbde3f68f80d 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
zero515 1:dbde3f68f80d 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
zero515 1:dbde3f68f80d 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
zero515 1:dbde3f68f80d 20 * THE SOFTWARE.
zero515 1:dbde3f68f80d 21 */
zero515 1:dbde3f68f80d 22
zero515 0:d90f3421aaef 23 #include "mbed.h"
zero515 0:d90f3421aaef 24 #include "TB6612.h"
zero515 0:d90f3421aaef 25 #include "SoftPWM.h"
zero515 0:d90f3421aaef 26
zero515 0:d90f3421aaef 27 DigitalOut led1(P2_11);
zero515 0:d90f3421aaef 28 DigitalOut led2(P0_2);
zero515 0:d90f3421aaef 29 DigitalOut led3(P0_7);
zero515 0:d90f3421aaef 30 DigitalOut led4(P0_3);
zero515 0:d90f3421aaef 31
zero515 0:d90f3421aaef 32 AnalogIn ad0(P0_11);
zero515 0:d90f3421aaef 33 AnalogIn ad1(P1_0);
zero515 0:d90f3421aaef 34 AnalogIn ad2(P1_1);
zero515 0:d90f3421aaef 35 AnalogIn ad3(P1_2);
zero515 0:d90f3421aaef 36 AnalogIn ad5(P1_4);
zero515 0:d90f3421aaef 37 AnalogIn ad7(P1_11);
zero515 0:d90f3421aaef 38
zero515 0:d90f3421aaef 39 TB6612 motor1a(P2_7,P2_9,P2_8);
zero515 0:d90f3421aaef 40 TB6612 motor1b(P2_4,P2_6,P2_5);
zero515 0:d90f3421aaef 41
zero515 0:d90f3421aaef 42 Serial pc(P1_7, P1_6);
zero515 0:d90f3421aaef 43
zero515 0:d90f3421aaef 44
zero515 0:d90f3421aaef 45 int main() {
zero515 0:d90f3421aaef 46 pc.baud(19200);
zero515 0:d90f3421aaef 47
zero515 0:d90f3421aaef 48 led1 = 0;
zero515 0:d90f3421aaef 49 led2 = 0;
zero515 0:d90f3421aaef 50 led3 = 0;
zero515 0:d90f3421aaef 51 led4 = 0;
zero515 0:d90f3421aaef 52 motor1a = 0.0;
zero515 0:d90f3421aaef 53 motor1b = 0.0;
zero515 0:d90f3421aaef 54
zero515 0:d90f3421aaef 55 while(1) {
zero515 0:d90f3421aaef 56
zero515 0:d90f3421aaef 57 led1 = 1;
zero515 0:d90f3421aaef 58 motor1a = 0.2; // Motor forward.
zero515 0:d90f3421aaef 59 wait(1.0);
zero515 0:d90f3421aaef 60 led1 = 0;
zero515 0:d90f3421aaef 61
zero515 0:d90f3421aaef 62 led2 = 1;
zero515 0:d90f3421aaef 63 motor1a = -0.2; // Motor reversal.
zero515 0:d90f3421aaef 64 wait(1.0);
zero515 0:d90f3421aaef 65 led2 = 0;
zero515 0:d90f3421aaef 66
zero515 0:d90f3421aaef 67 motor1a = 0.0;
zero515 0:d90f3421aaef 68
zero515 0:d90f3421aaef 69 led3 = 1;
zero515 0:d90f3421aaef 70 motor1b = 0.2; // Motor forward.
zero515 0:d90f3421aaef 71 wait(1.0);
zero515 0:d90f3421aaef 72 led3 = 0;
zero515 0:d90f3421aaef 73
zero515 0:d90f3421aaef 74 led4 = 1;
zero515 0:d90f3421aaef 75 motor1b = -0.2; // Motor reversal.
zero515 0:d90f3421aaef 76 wait(1.0);
zero515 0:d90f3421aaef 77 led4 = 0;
zero515 0:d90f3421aaef 78
zero515 0:d90f3421aaef 79 motor1b = 0.0;
zero515 0:d90f3421aaef 80
zero515 0:d90f3421aaef 81 pc.printf("check_ok \r\n");
zero515 0:d90f3421aaef 82 }
zero515 0:d90f3421aaef 83 }