mbed robotracer for education.

Robotracer (line follower robot ) using stepper motor.

/media/uploads/hayama/cimg8463.jpg

/media/uploads/hayama/mbedrobotracer-manual-english.pdf

/media/uploads/hayama/mbedrobotracer-manual-japanese.pdf

/media/uploads/hayama/eagle-design-robotracer.zip

movie -> https://www.youtube.com/watch?v=INwun8gSds4

(for competition->) https://www.youtube.com/watch?v=l_gP2pUt4w0

Committer:
hayama
Date:
Wed Jun 19 10:00:41 2013 +0000
Revision:
0:da22b0b4395a
mbed robotracer for education ver 1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hayama 0:da22b0b4395a 1 /* mbed Microcontroller Library
hayama 0:da22b0b4395a 2 * Copyright (c) 2006-2013 ARM Limited
hayama 0:da22b0b4395a 3 *
hayama 0:da22b0b4395a 4 * Licensed under the Apache License, Version 2.0 (the "License");
hayama 0:da22b0b4395a 5 * you may not use this file except in compliance with the License.
hayama 0:da22b0b4395a 6 * You may obtain a copy of the License at
hayama 0:da22b0b4395a 7 *
hayama 0:da22b0b4395a 8 * http://www.apache.org/licenses/LICENSE-2.0
hayama 0:da22b0b4395a 9 *
hayama 0:da22b0b4395a 10 * Unless required by applicable law or agreed to in writing, software
hayama 0:da22b0b4395a 11 * distributed under the License is distributed on an "AS IS" BASIS,
hayama 0:da22b0b4395a 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
hayama 0:da22b0b4395a 13 * See the License for the specific language governing permissions and
hayama 0:da22b0b4395a 14 * limitations under the License.
hayama 0:da22b0b4395a 15 */
hayama 0:da22b0b4395a 16 #ifndef MBED_PORTIN_H
hayama 0:da22b0b4395a 17 #define MBED_PORTIN_H
hayama 0:da22b0b4395a 18
hayama 0:da22b0b4395a 19 #include "platform.h"
hayama 0:da22b0b4395a 20
hayama 0:da22b0b4395a 21 #if DEVICE_PORTIN
hayama 0:da22b0b4395a 22
hayama 0:da22b0b4395a 23 #include "port_api.h"
hayama 0:da22b0b4395a 24
hayama 0:da22b0b4395a 25 namespace mbed {
hayama 0:da22b0b4395a 26
hayama 0:da22b0b4395a 27 /** A multiple pin digital input
hayama 0:da22b0b4395a 28 *
hayama 0:da22b0b4395a 29 * Example:
hayama 0:da22b0b4395a 30 * @code
hayama 0:da22b0b4395a 31 * // Switch on an LED if any of mbed pins 21-26 is high
hayama 0:da22b0b4395a 32 *
hayama 0:da22b0b4395a 33 * #include "mbed.h"
hayama 0:da22b0b4395a 34 *
hayama 0:da22b0b4395a 35 * PortIn p(Port2, 0x0000003F); // p21-p26
hayama 0:da22b0b4395a 36 * DigitalOut ind(LED4);
hayama 0:da22b0b4395a 37 *
hayama 0:da22b0b4395a 38 * int main() {
hayama 0:da22b0b4395a 39 * while(1) {
hayama 0:da22b0b4395a 40 * int pins = p.read();
hayama 0:da22b0b4395a 41 * if(pins) {
hayama 0:da22b0b4395a 42 * ind = 1;
hayama 0:da22b0b4395a 43 * } else {
hayama 0:da22b0b4395a 44 * ind = 0;
hayama 0:da22b0b4395a 45 * }
hayama 0:da22b0b4395a 46 * }
hayama 0:da22b0b4395a 47 * }
hayama 0:da22b0b4395a 48 * @endcode
hayama 0:da22b0b4395a 49 */
hayama 0:da22b0b4395a 50 class PortIn {
hayama 0:da22b0b4395a 51 public:
hayama 0:da22b0b4395a 52
hayama 0:da22b0b4395a 53 /** Create an PortIn, connected to the specified port
hayama 0:da22b0b4395a 54 *
hayama 0:da22b0b4395a 55 * @param port Port to connect to (Port0-Port5)
hayama 0:da22b0b4395a 56 * @param mask A bitmask to identify which bits in the port should be included (0 - ignore)
hayama 0:da22b0b4395a 57 */
hayama 0:da22b0b4395a 58 PortIn(PortName port, int mask = 0xFFFFFFFF) {
hayama 0:da22b0b4395a 59 port_init(&_port, port, mask, PIN_INPUT);
hayama 0:da22b0b4395a 60 }
hayama 0:da22b0b4395a 61
hayama 0:da22b0b4395a 62 /** Read the value currently output on the port
hayama 0:da22b0b4395a 63 *
hayama 0:da22b0b4395a 64 * @returns
hayama 0:da22b0b4395a 65 * An integer with each bit corresponding to associated port pin setting
hayama 0:da22b0b4395a 66 */
hayama 0:da22b0b4395a 67 int read() {
hayama 0:da22b0b4395a 68 return port_read(&_port);
hayama 0:da22b0b4395a 69 }
hayama 0:da22b0b4395a 70
hayama 0:da22b0b4395a 71 /** Set the input pin mode
hayama 0:da22b0b4395a 72 *
hayama 0:da22b0b4395a 73 * @param mode PullUp, PullDown, PullNone, OpenDrain
hayama 0:da22b0b4395a 74 */
hayama 0:da22b0b4395a 75 void mode(PinMode mode) {
hayama 0:da22b0b4395a 76 port_mode(&_port, mode);
hayama 0:da22b0b4395a 77 }
hayama 0:da22b0b4395a 78
hayama 0:da22b0b4395a 79 /** A shorthand for read()
hayama 0:da22b0b4395a 80 */
hayama 0:da22b0b4395a 81 operator int() {
hayama 0:da22b0b4395a 82 return read();
hayama 0:da22b0b4395a 83 }
hayama 0:da22b0b4395a 84
hayama 0:da22b0b4395a 85 private:
hayama 0:da22b0b4395a 86 port_t _port;
hayama 0:da22b0b4395a 87 };
hayama 0:da22b0b4395a 88
hayama 0:da22b0b4395a 89 } // namespace mbed
hayama 0:da22b0b4395a 90
hayama 0:da22b0b4395a 91 #endif
hayama 0:da22b0b4395a 92
hayama 0:da22b0b4395a 93 #endif