Robot C-program for Group C-1 (wind), E5 Fall 2002
Jeremy Cristol
Heather Jones
Joe Raciti
void playsong(void)
{tone(659.26,2.0);tone(622.25,.5);tone(659.26,.5);tone(622.25,.75);
tone(493.88,.75);tone(415.30,.25);tone(554.37,.5);tone(415.30,.75);
tone(440.0,1.0);tone(493.88,.666);tone(493.88,.333);tone(659.26,2.0);
tone(739.99,.5);tone(830.61,.5);tone(987.77,.5);tone(830.61,.75);
tone(403.88,.25);tone(554.37,.25);tone(622.25,.25);tone(554.37,.25);
}
void turnaround (void)
{ printf("\nbumped");
beep();
motor(0,-100);
motor(1,-100);
sleep(2.0);
motor(0,100);
sleep(2.7);
motor(1,100);
printf("\n");}
void main(void)
{
int m,i,l,x,y,z;
i=0;
m=255;
l=analog(2);
motor(0,70);
motor(1,70);
sleep(3.0);
while(!stop_button())
{while(i<m && !stop_button())
{while(x=digital(7)&& y=digital(8) &&z=!stop_button())
{
if(analog(2)-(analog(3)-4) >15)
{motor(1,0);
motor(0,70);
sleep(1.0);
}
else
{if(analog(2)-(analog(3)-4) <-15)
{motor(1,70);
motor(0,0);
sleep(1.0);}
else
{ao();
if(analog(2)>80 && (analog(3)-4) >80)
{i=260;
printf("\nmax=%d",analog(2));
playsong();
}
else{
if(analog(2)>l){
l=analog(2);
printf("\nlocal max=%d",analog(2));
beep();
sleep(0.5);
motor(1,70);
motor(0,70);
sleep(2.0);}
else{motor(0,70);
motor(1,70);
sleep(2.0);}}
}}}
if(z)
{turnaround();
}}
}
ao();}