Skip to content

Instantly share code, notes, and snippets.

@reginaldojunior
Created May 4, 2017 01:04
Show Gist options
  • Save reginaldojunior/cba7b2fa484ad80f646c971028a73c27 to your computer and use it in GitHub Desktop.
Save reginaldojunior/cba7b2fa484ad80f646c971028a73c27 to your computer and use it in GitHub Desktop.
codigo-robo.c
#define THRESHOLD 45
void lancaBola() {
OnRev(OUT_C, 100);
Wait(200);
OnFwd(OUT_C, 100);
Wait(200);
Off(OUT_C);
}
void pararRodas() {
OnRev(OUT_AB, 30);
Wait(500);
Off(OUT_AB);
}
void sensor(){
SetSensorLight(IN_3);
OnFwd(OUT_AB, 35);
Wait(100);
while (true)
{
if (Sensor(IN_3) < THRESHOLD)
{
pararRodas();
lancaBola();
until(Sensor(IN_3) >= THRESHOLD);
}
}
}
task main() {
sensor();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment