Create this program

Dependencies:   mbed HCSR04 HMC6352 PID TextLCD

Revision:
5:e07e380ddb93
Parent:
3:901d18b901b4
--- a/infrared.h	Fri Aug 07 06:51:51 2015 +0000
+++ b/infrared.h	Sat Aug 08 12:39:18 2015 +0000
@@ -1,5 +1,5 @@
 /**
- * @file   : infrared.h (0.1)
+ * @file   : infrared.h (1.0)
  * @brief  : examine point the ball exist
  * @author : Shinnosuke KOIKE
  * @date   : 2015/08/04
@@ -37,22 +37,26 @@
     AnalogIn analogFrontRight;
 };
 
+// initialize
 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) {
 }
 
+// return ball position
 char Infrared::findBallPos(void) {
     char data = infraredData;
     return data;
 }
 
+// initialize
 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) {
 }
 
+// return ball position and distance
 void AnalogInfrared::findBallPosAndDist(char data[]) {
     data[0] = analogFront;
     data[1] = analogFrontLeft;
@@ -65,3 +69,34 @@
 }
 
 #endif
+
+/**
+ * example program(normal)
+
+#include "mbed.h"
+#include "infrared.h"
+
+int main(void) {
+    Infrared infrared(D0, D1, D2, D3, D4, D5, D6, D7);
+    while (1) {
+        char data = infrared.findBallPos();
+        pc.printf("%d\r\n", data);  // for example, display "11000001"
+    }
+}
+
+ * example program(analog)
+
+#include "mbed.h"
+#include "infrared.h"
+
+int main(void) {
+    int data[8];
+    AnalogInfrared analogInfrared(D0, D1, D2, D3, D4, D5, D6, D7);
+    while (1) {
+        analogInfrared.findBallPosAndDist(data);
+        for (int i = 0; i < 8; i++) {
+            pc.printf("%f\r\n", data[i]);   // for example, display "123, 212, 0, 0, ..."
+        }
+    }
+}
+ */