Paste these into main.cpp and platformio.ini respectively:
main.cpp
#include <Arduino.h>
#include <zirconLib.h>
void setup(void)
{
Serial.begin(115200);
InitializeZircon();
}
void loop(void)
{
Serial.println("reading sensors ");
Serial.println("ball sensor 1: " + String(readBall(1)));
Serial.println("ball sensor 2: " + String(readBall(2)));
Serial.println("ball sensor 3: " + String(readBall(3)));
Serial.println("ball sensor 4: " + String(readBall(4)));
Serial.println("ball sensor 5: " + String(readBall(5)));
Serial.println("ball sensor 6: " + String(readBall(6)));
Serial.println("ball sensor 7: " + String(readBall(7)));
Serial.println("ball sensor 8: " + String(readBall(8)));
Serial.println("push button 1: " + String(readButton(1)));
Serial.println("push button 2: " + String(readButton(2)));
Serial.println("orientation: " + String(readCompass()));
Serial.println("current runtime: " + String(millis()) + " milliseconds");
Serial.println("--------------------------------------");
}
platformio.ini
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
lib_deps = clamepending/ZirconLib@^1.0.33
This is the program for a basic soccer robot:
#include <Arduino.h>
#include <zirconLib.h>
int goalAngle = 0;
void setup(void)
{
Serial.begin(115200);
InitializeZircon();
while (readButton(1) == 0) {
goalAngle = readCompass();
}
}
void loop(void)
{
if (readBall(1) > 650) {
if (abs(goalAngle - readCompass()) < 30) {
motor1(100, 0);
motor2(100, 1);
motor3(0, 0);
} else {
motor1(70, 0);
motor2(10, 1);
motor3(70, 1);
}
} else {
motor1(40, 1);
motor2(40, 1);
motor3(40, 1);
}
}