Last active
May 16, 2020 10:54
-
-
Save Tasssadar/4975cb281e24809d64e65cac64b5bab3 to your computer and use it in GitHub Desktop.
Jak programovat roboty?
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
#include <Arduino.h> | |
#include "roboruka.h" | |
void setup() | |
{ | |
Robot.begin(); | |
printf("Robot nastartovan!\n"); | |
} | |
void loop() | |
{ | |
if(Buttons.isPressed(0)) { | |
Leds.red(true); | |
} else { | |
Leds.red(false); | |
} | |
Leds.green(Buttons.isPressed(1)); | |
if(Buttons.isPressed(2)) { | |
Motors.set(50, 50); | |
} else { | |
Motors.set(0, 0); | |
} | |
if(Buttons.isPressed(3)) { | |
// Encoders.distanceLeft(), možná | |
printf("Ujetá vzálenost: %d %d\n", Motors.distanceLeft(), Motors.distanceRight()); | |
delay(1000); | |
} | |
} |
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
#include <Arduino.h> | |
#include "roboruka.h" | |
void setup() | |
{ | |
rkSetup(); | |
printf("Robot nastartovan!\n"); | |
} | |
void loop() | |
{ | |
if(rkButtonIsPressed(1)) { | |
rkLedRed(true); | |
} else { | |
rkLedRed(false); | |
} | |
rkLedGreen(rkButtonIsPressed(2)); | |
if(rkButtonIsPressed(3)) { | |
rkMotorsSetPower(50, 50); | |
} else { | |
rkMotorsSetPower(0, 0); | |
} | |
if(rkButtonIsPressed(4)) { | |
printf("Ujetá vzálenost motorů: %d %d\n", rkMotorsGetDistanceLeft(), rkMotorsGetDistanceRight()); | |
delay(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment