Create this program

Dependencies:   mbed HCSR04 HMC6352 PID TextLCD

Committer:
KoiShin_Sakana
Date:
Tue Aug 11 13:11:05 2015 +0000
Revision:
6:44c3bfbe2553
Parent:
5:e07e380ddb93
update dribbler.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
KoiShin_Sakana 3:901d18b901b4 1 /**
KoiShin_Sakana 5:e07e380ddb93 2 * @file : line.h (1.0)
KoiShin_Sakana 3:901d18b901b4 3 * @brief : find white line
KoiShin_Sakana 3:901d18b901b4 4 * @author : Shinnosuke KOIKE
KoiShin_Sakana 3:901d18b901b4 5 * @date : 2015/08/07
KoiShin_Sakana 3:901d18b901b4 6 */
KoiShin_Sakana 3:901d18b901b4 7
KoiShin_Sakana 3:901d18b901b4 8 #ifndef LINE_H
KoiShin_Sakana 3:901d18b901b4 9 #define LINE_H
KoiShin_Sakana 3:901d18b901b4 10
KoiShin_Sakana 3:901d18b901b4 11 #include "mbed.h"
KoiShin_Sakana 3:901d18b901b4 12
KoiShin_Sakana 3:901d18b901b4 13 class Line {
KoiShin_Sakana 5:e07e380ddb93 14 public:
KoiShin_Sakana 5:e07e380ddb93 15 Line(PinName right, PinName back, PinName left);
KoiShin_Sakana 5:e07e380ddb93 16 char findOnLine(void);
KoiShin_Sakana 5:e07e380ddb93 17
KoiShin_Sakana 5:e07e380ddb93 18 private:
KoiShin_Sakana 5:e07e380ddb93 19 BusIn lineData;
KoiShin_Sakana 3:901d18b901b4 20 };
KoiShin_Sakana 3:901d18b901b4 21
KoiShin_Sakana 5:e07e380ddb93 22 // initialize
KoiShin_Sakana 5:e07e380ddb93 23 Line::Line(PinName right, PinName back, PinName left):
KoiShin_Sakana 5:e07e380ddb93 24 lineData(right, back, left) {
KoiShin_Sakana 5:e07e380ddb93 25 }
KoiShin_Sakana 5:e07e380ddb93 26
KoiShin_Sakana 5:e07e380ddb93 27 // return data which if the robot get on white line
KoiShin_Sakana 5:e07e380ddb93 28 char Line::findOnLine(void) {
KoiShin_Sakana 5:e07e380ddb93 29 char data = lineData;
KoiShin_Sakana 5:e07e380ddb93 30 return data;
KoiShin_Sakana 5:e07e380ddb93 31 }
KoiShin_Sakana 5:e07e380ddb93 32
KoiShin_Sakana 5:e07e380ddb93 33 #endif
KoiShin_Sakana 5:e07e380ddb93 34
KoiShin_Sakana 5:e07e380ddb93 35 /**
KoiShin_Sakana 5:e07e380ddb93 36 * example program
KoiShin_Sakana 5:e07e380ddb93 37
KoiShin_Sakana 5:e07e380ddb93 38 #include "mbed.h"
KoiShin_Sakana 5:e07e380ddb93 39 #include "line.h"
KoiShin_Sakana 5:e07e380ddb93 40
KoiShin_Sakana 5:e07e380ddb93 41 int main(void) {
KoiShin_Sakana 5:e07e380ddb93 42 Line line(D0, D1, D2);
KoiShin_Sakana 5:e07e380ddb93 43 while (1) {
KoiShin_Sakana 5:e07e380ddb93 44 char data = line.findOnLine();
KoiShin_Sakana 5:e07e380ddb93 45 pc.printf("%d\r\n", data); // for example, display "1 0 0"
KoiShin_Sakana 5:e07e380ddb93 46 }
KoiShin_Sakana 5:e07e380ddb93 47 }
KoiShin_Sakana 5:e07e380ddb93 48 */