Library for the CustomExplorerRobot.

Dependents:   CustomExplorerRobot_test

Committer:
Usuke
Date:
Sat Feb 27 10:04:22 2016 +0000
Revision:
1:dce53bcd79a4
Parent:
0:ad4667fc5a76
??

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Usuke 0:ad4667fc5a76 1 /* mbed CustomExplorerRobot Library
Usuke 0:ad4667fc5a76 2 *
Usuke 1:dce53bcd79a4 3 * CustomExplorerRobot.cpp
Usuke 0:ad4667fc5a76 4 *
Usuke 1:dce53bcd79a4 5 * Copyright (c) 2016 Yusuke Aihara
Usuke 0:ad4667fc5a76 6 *
Usuke 0:ad4667fc5a76 7 * Permission is hereby granted, free of charge, to any person obtaining a copy
Usuke 0:ad4667fc5a76 8 * of this software and associated documentation files (the "Software"), to deal
Usuke 0:ad4667fc5a76 9 * in the Software without restriction, including without limitation the rights
Usuke 0:ad4667fc5a76 10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Usuke 0:ad4667fc5a76 11 * copies of the Software, and to permit persons to whom the Software is
Usuke 0:ad4667fc5a76 12 * furnished to do so, subject to the following conditions:
Usuke 0:ad4667fc5a76 13 *
Usuke 0:ad4667fc5a76 14 * The above copyright notice and this permission notice shall be included in
Usuke 0:ad4667fc5a76 15 * all copies or substantial portions of the Software.
Usuke 0:ad4667fc5a76 16 *
Usuke 0:ad4667fc5a76 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Usuke 0:ad4667fc5a76 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Usuke 0:ad4667fc5a76 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Usuke 0:ad4667fc5a76 20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Usuke 0:ad4667fc5a76 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Usuke 0:ad4667fc5a76 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Usuke 0:ad4667fc5a76 23 * THE SOFTWARE.
Usuke 0:ad4667fc5a76 24 */
Usuke 0:ad4667fc5a76 25
Usuke 0:ad4667fc5a76 26 #include "mbed.h"
Usuke 0:ad4667fc5a76 27 #include "CustomExplorerRobot.h"
Usuke 0:ad4667fc5a76 28
Usuke 0:ad4667fc5a76 29 CustomExplorerRobot::CustomExplorerRobot() : _right(PC_7, PC_6), _left(PC_8, PC_9), _redled(PC_5), _blueled(PA_12), _buzzer(PA_11) {
Usuke 0:ad4667fc5a76 30 _right = 0.0f;
Usuke 0:ad4667fc5a76 31 _left = 0.0f;
Usuke 0:ad4667fc5a76 32 _redled = 1.0f;
Usuke 0:ad4667fc5a76 33 _blueled = 1.0f;
Usuke 0:ad4667fc5a76 34 _buzzer = 0.0f;
Usuke 0:ad4667fc5a76 35 }
Usuke 0:ad4667fc5a76 36
Usuke 0:ad4667fc5a76 37 void CustomExplorerRobot::left_motor(float speed){
Usuke 0:ad4667fc5a76 38 _left = speed;
Usuke 0:ad4667fc5a76 39 }
Usuke 0:ad4667fc5a76 40
Usuke 0:ad4667fc5a76 41 void CustomExplorerRobot::right_motor(float speed){
Usuke 0:ad4667fc5a76 42 _right = speed;
Usuke 0:ad4667fc5a76 43 }
Usuke 0:ad4667fc5a76 44
Usuke 0:ad4667fc5a76 45 void CustomExplorerRobot::forward(float speed){
Usuke 0:ad4667fc5a76 46 _left = speed;
Usuke 0:ad4667fc5a76 47 _right = speed;
Usuke 0:ad4667fc5a76 48 }
Usuke 0:ad4667fc5a76 49
Usuke 0:ad4667fc5a76 50 void CustomExplorerRobot::backward(float speed){
Usuke 0:ad4667fc5a76 51 _left = -speed;
Usuke 0:ad4667fc5a76 52 _right = -speed;
Usuke 0:ad4667fc5a76 53 }
Usuke 0:ad4667fc5a76 54
Usuke 0:ad4667fc5a76 55 void CustomExplorerRobot::left(float speed){
Usuke 0:ad4667fc5a76 56 _left = -speed;
Usuke 0:ad4667fc5a76 57 _right = speed;
Usuke 0:ad4667fc5a76 58 }
Usuke 0:ad4667fc5a76 59
Usuke 0:ad4667fc5a76 60 void CustomExplorerRobot::right(float speed){
Usuke 0:ad4667fc5a76 61 _left = speed;
Usuke 0:ad4667fc5a76 62 _right = -speed;
Usuke 0:ad4667fc5a76 63 }
Usuke 0:ad4667fc5a76 64
Usuke 0:ad4667fc5a76 65 void CustomExplorerRobot::stop(void){
Usuke 0:ad4667fc5a76 66 _left = 0.0f;
Usuke 0:ad4667fc5a76 67 _right = 0.0f;
Usuke 0:ad4667fc5a76 68 }