Skip to content

Instantly share code, notes, and snippets.

@Tasssadar
Last active May 16, 2020
Embed
What would you like to do?
Jak programovat roboty?
#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);
}
}
#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