Create this program

Dependencies:   mbed HCSR04 HMC6352 PID TextLCD

Revision:
3:901d18b901b4
Parent:
2:a8bbf677e774
Child:
5:e07e380ddb93
diff -r a8bbf677e774 -r 901d18b901b4 infrared.h
--- a/infrared.h	Thu Aug 06 00:19:29 2015 +0000
+++ b/infrared.h	Fri Aug 07 06:34:36 2015 +0000
@@ -1,6 +1,6 @@
 /**
  * @file   : infrared.h (0.1)
- * @brief  : 
+ * @brief  : examine point the ball exist
  * @author : Shinnosuke KOIKE
  * @date   : 2015/08/04
  */
@@ -11,7 +11,57 @@
 #include "mbed.h"
 
 class Infrared {
-    
+public:
+    Infrared(PinName front, PinName frontLeft, PinName left, PinName backLeft,
+        PinName back, PinName backRight, PinName right, PinName frontRight);
+    char findBallPos(void);
+
+private:
+    BusIn infraredData;
+};
+
+class AnalogInfrared {
+public:
+    AnalogInfrared(PinName front, PinName frontLeft, PinName left, PinName backLeft,
+        PinName back, PinName backRight, PinName right, PinName frontRight);
+    void findBallPosAndDist(char data[]);
+
+private:
+    AnalogIn analogFront;
+    AnalogIn analogFrontLeft;
+    AnalogIn analogLeft;
+    AnalogIn analogBackLeft;
+    AnalogIn analogBack;
+    AnalogIn analogBackRight;
+    AnalogIn analogRight;
+    AnalogIn analogFrontRight;
 };
 
+Infrared::Infrared(PinName front, PinName frontLeft, PinName left, PinName backLeft,
+        PinName back, PinName backRight, PinName right, PinName frontRight):
+    infraredData(front, frontLeft, left, backLeft, back, backRight, right, frontRight) {
+}
+
+char Infrared::findBallPos(void) {
+    char data = infraredData;
+    return data;
+}
+
+AnalogInfrared::AnalogInfrared(PinName front, PinName frontLeft, PinName left, PinName backLeft,
+        PinName back, PinName backRight, PinName right, PinName frontRight):
+    analogFront(front), analogFrontLeft(frontLeft), analogLeft(left), analogBackLeft(backLeft),
+    analogBack(back), analogBackRight(backRight), analogRight(right), analogFrontRight(frontRight) {
+}
+
+void AnalogInfrared::findBallPosAndDist(char data[]) {
+    data[0] = analogFront;
+    data[1] = analogFrontLeft;
+    data[2] = analogLeft;
+    data[3] = analogBackLeft;
+    data[4] = analogBack;
+    data[5] = analogBackRight;
+    data[6] = analogRight;
+    data[7] = analogFrontRight;
+}
+
 #endif