これは足をうごめかす何かです。

Dependencies:   mbed

Revision:
0:6ca09b29723e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 16 09:31:13 2014 +0000
@@ -0,0 +1,90 @@
+/*send  すいっちの簡単版*/
+#include "mbed.h"
+AnalogIn aa(p19);
+AnalogIn bb(p17);
+//DigitalIn sw4[4]={p12,p13,p14,p15};
+DigitalIn switch_on(p15);
+//DigitalIn switch_rt(p14);
+//DigitalIn switch_lu(p13);
+//DigitalIn switch_lt(p12);
+Serial pc(USBTX,USBRX);
+Serial Xbee (p28,p27);//p9, p10
+void SetUp(void);
+
+void Setup(void){
+    /*
+    sw4[0].mode(PullUp);
+    sw4[1].mode(PullUp);
+    sw4[2].mode(PullUp);
+    sw4[3].mode(PullUp);
+    */
+    
+    switch_on.mode(PullUp);
+    //switch_rt.mode(PullUp);
+    //switch_lu.mode(PullUp);
+    //switch_lt.mode(PullUp);
+    
+    uint8_t i=1;
+ 
+    Xbee.putc(i);
+    }
+    
+int main() {
+    
+    unsigned int c1,c2;
+    int data,rd,ld,swon;    
+    
+    count=1;
+
+    Setup();
+
+    c1=aa.read_u16();  //中央値
+    c2=bb.read_u16();  //  
+    
+    while(1) {
+        rd=ld=0;
+        swon=0;
+        
+        /*   LEFT   */
+        
+        if(bb.read_u16()>(c2*1.2)){
+                ld=0x80;//10000000       128  
+            
+        }else if((bb.read_u16() >= 0 )&&(bb.read_u16()<(c2 * 0.7))){
+           
+                ld=0x40;//01000000       64 
+                
+        }
+    
+        /*  RIGHT   */
+        
+        if(aa.read_u16()>(c1*1.2)){
+                rd=0x20;//00100000   32   
+                
+        }else if((aa.read_u16() >= 0 )&&(aa.read_u16()<(c1 * 0.7))){
+
+                rd=0x10;//00010000     16 
+    
+        }
+ 
+            swon=!switch_on;
+            
+        /*    
+        swlu=!sw4[0];
+        swlt=!sw4[1];
+        swrt=!sw4[2];
+        swru=!sw4[3];
+         */
+         
+        data=rd+ld+swon;        //
+        
+        //pc.printf("%d\n",swon);
+        pc.printf("%d\n",data);
+        
+        //pc.printf("%d  %d  %d  %d\n",lt,lu,rt,ru);
+        //pc.printf("%d\n",swrt);
+        
+        Xbee.putc(data);
+        
+    }
+}