Created
May 4, 2017 01:04
-
-
Save reginaldojunior/cba7b2fa484ad80f646c971028a73c27 to your computer and use it in GitHub Desktop.
codigo-robo.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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