Image Zoom In/out Sample. This program uses GraphicsFramework library and GP2Y0A21YK sensor. Please use distance sensor in the range of 10-30cm.

Dependencies:   GR-PEACH_video GraphicsFramework R_BSP mbed-rtos mbed

Fork of RGA_HelloWorld by Renesas

About GP2Y0A21YK

GP2Y0A21YK is a distance sensor and can be controlled by using the AnalogIn.
The range of this sensor is 10-80cm.

About wiring

SensorGR-PEACH
White wireA0
Orange wireGND
Black wire5.0V
Revision:
6:6cad61e4a4c1
Parent:
5:ac895a9527ab
--- a/main.cpp	Fri May 13 07:10:27 2016 +0000
+++ b/main.cpp	Fri May 20 02:33:41 2016 +0000
@@ -55,18 +55,18 @@
 }
 
 static float get_distance(void) {
-    float tmp[10];
+    float tmp = 0;
     float data = 0;
     float distance = 0;
     int cnt;
 
     for (cnt = 0; cnt < 10; cnt++) {
-        tmp[cnt] = ain;
-        if (tmp[cnt] == 0) {
+        if (ain == 0) {
             return 0;
         }
+        tmp = tmp + ain;
     }
-    data = (tmp[0]+tmp[1]+tmp[2]+tmp[3]+tmp[4]+tmp[5]+tmp[6]+tmp[7]+tmp[8]+tmp[9]) / 10;
+    data = tmp / 10;
     if ((data >= 0.121) && (data <= 0.970)) {
         distance = 26.663 * pow((data * 3.3), -1.25);
     }