2

‪#‎include‬ "mbed.h" AnalogIn ain(A0); Serial pc(USBTX, USBRX); PwmOut mypwm(PWM_OUT); DigitalOut led(D8); int count=0; int n,a;

void recieve(){ count = count + 1; pc.printf("object = %d\n",count); } void man(){ switch(n){ case 0 : led = 0; break; case 1 : led = 1; ecieve(); break; /*se 2: recieve(); break;*/ default: break; } } void sad(){ if (ain>0.3f){ n=1; man(); if(a==1){ recieve(); a=0; } } /*r (n=1;n<=3;n++){ man(); n=3; if (n==3)break; } }*/ else { n=0; man(); a=1; } }

int main(){ while(1) { sad(); wait(0.5f); } }


Please log in to post comments.