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.
Dependents: CustomExplorerRobot_test
CustomExplorerRobot.cpp
00001 /* mbed CustomExplorerRobot Library 00002 * 00003 * CustomExplorerRobot.cpp 00004 * 00005 * Copyright (c) 2016 Yusuke Aihara 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a copy 00008 * of this software and associated documentation files (the "Software"), to deal 00009 * in the Software without restriction, including without limitation the rights 00010 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00011 * copies of the Software, and to permit persons to whom the Software is 00012 * furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included in 00015 * all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00018 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00020 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00021 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00022 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00023 * THE SOFTWARE. 00024 */ 00025 00026 #include "mbed.h" 00027 #include "CustomExplorerRobot.h" 00028 00029 CustomExplorerRobot::CustomExplorerRobot() : _right(PC_7, PC_6), _left(PC_8, PC_9), _redled(PC_5), _blueled(PA_12), _buzzer(PA_11) { 00030 _right = 0.0f; 00031 _left = 0.0f; 00032 _redled = 1.0f; 00033 _blueled = 1.0f; 00034 _buzzer = 0.0f; 00035 } 00036 00037 void CustomExplorerRobot::left_motor(float speed){ 00038 _left = speed; 00039 } 00040 00041 void CustomExplorerRobot::right_motor(float speed){ 00042 _right = speed; 00043 } 00044 00045 void CustomExplorerRobot::forward(float speed){ 00046 _left = speed; 00047 _right = speed; 00048 } 00049 00050 void CustomExplorerRobot::backward(float speed){ 00051 _left = -speed; 00052 _right = -speed; 00053 } 00054 00055 void CustomExplorerRobot::left(float speed){ 00056 _left = -speed; 00057 _right = speed; 00058 } 00059 00060 void CustomExplorerRobot::right(float speed){ 00061 _left = speed; 00062 _right = -speed; 00063 } 00064 00065 void CustomExplorerRobot::stop(void){ 00066 _left = 0.0f; 00067 _right = 0.0f; 00068 }
Generated on Tue Jul 19 2022 20:04:29 by
1.7.2
Custom Explorer Robot