Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of sagawa_lpc1114 by
main.cpp
00001 /* 00002 * Copyright (c) 2012-2016 Sagawa Electronics,inc. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 * THE SOFTWARE. 00021 */ 00022 00023 #include "mbed.h" 00024 #include "TB6612.h" 00025 #include "SoftPWM.h" 00026 00027 DigitalOut led1(P2_11); // LDE1 setting. 00028 DigitalOut led2(P0_2); // LDE2 setting. 00029 DigitalOut led3(P0_7); // LDE3 setting. 00030 DigitalOut led4(P0_3); // LDE4 setting. 00031 00032 AnalogIn ad0(P0_11); //AD0port setting. 00033 AnalogIn ad1(P1_0); //AD1port setting. 00034 AnalogIn ad2(P1_1); //AD2port setting. 00035 AnalogIn ad3(P1_2); //AD3port setting. 00036 AnalogIn ad5(P1_4); //AD5port setting. 00037 AnalogIn ad7(P1_11); //AD7port setting. 00038 00039 TB6612 motor1a(P2_7,P2_9,P2_8); //TB6612 setting. 00040 TB6612 motor1b(P2_4,P2_6,P2_5); //TB6612 setting. 00041 00042 Serial pc(P1_7, P1_6); 00043 00044 00045 int main() { 00046 pc.baud(19200); 00047 00048 led1 = 0; 00049 led2 = 0; 00050 led3 = 0; 00051 led4 = 0; 00052 motor1a = 0.0; 00053 motor1b = 0.0; 00054 00055 while(1) { 00056 00057 led1 = 1; // LDE1 enable. 00058 motor1a = 0.2; // Motor1A forward. 00059 wait(1.0); //wait 1 second. 00060 led1 = 0; // LDE1 disable. 00061 00062 led2 = 1; // LDE2 enable. 00063 motor1a = -0.2; // Motor1A reversal. 00064 wait(1.0); //wait 1 second. 00065 led2 = 0; // LDE1 disable. 00066 00067 motor1a = 0.0; // Motor1A brake. 00068 00069 led3 = 1; // LDE3 enable. 00070 motor1b = 0.2; // Motor1B forward. 00071 wait(1.0); //wait 1 second. 00072 led3 = 0; // LDE1 disable. 00073 00074 led4 = 1; // LDE4 enable. 00075 motor1b = -0.2; // Motor1B reversal. 00076 wait(1.0); //wait 1 second. 00077 led4 = 0; // LDE1 disable. 00078 00079 motor1b = 0.0; // Motor1B brake. 00080 00081 pc.printf("check_ok \r\n"); 00082 } 00083 }
Generated on Sat Aug 6 2022 18:01:58 by
1.7.2
