12.07.2015 Views

Handyboard and Kit Manual (A.K.A. - Botball Programming Guide)

Handyboard and Kit Manual (A.K.A. - Botball Programming Guide)

Handyboard and Kit Manual (A.K.A. - Botball Programming Guide)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

© 2002 D.Miller, KIPR29IC: if () … else• Syntax recap: if () { …} else { …}void main(){if(digital(15)==1) /* select “forward” case */{motor(3,50);printf(“Forward\n”);}else /* select “reverse” case */}{motor(3,-75);printf(“Reverse\n”);}sleep(2.0); /* let motor run 2 secs */off(3); /* stop motor */© 2002 D.Miller, KIPR30IC: Selection Nested in Loopvoid main(){while (stop_button()==0) /* loop until stop */{if(digital(15)==1) /* select “forward” case */{motor(3,50);printf(“Forward\n”);}else /* select “reverse” case */{motor(3,-75);printf(“Reverse\n”);}sleep(2.0); /* let motor run for 2 secs */}off(3); /* turn off motor */}Teaser: what happens if you press <strong>and</strong> release stop while it is sleeping?15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!