Skip to content

Instantly share code, notes, and snippets.

@attilavago
Created January 2, 2017 22:40
Show Gist options
  • Save attilavago/1a0c14eb5654a56c6c7973626f309594 to your computer and use it in GitHub Desktop.
Save attilavago/1a0c14eb5654a56c6c7973626f309594 to your computer and use it in GitHub Desktop.
This test demonstrates getting the tilt value from a gyro sensor
import RobotKit
// Initializes a new EV3Robot instance through which all device communication happens
let robot = try EV3Robot()
// Sets up a gyro sensor at input port 1
guard let gyroSensor = robot.gyroSensor(atPort: .one) else {
fatalError("No gyro sensor at the given port!")
}
// Continues until the program is stopped
while true {
// Reads the tilt value as a number and outputs to the console
let ten = gyroSensor.waitUntilAngleIs(.lessThanOrEqualTo, threshold: 90)
print("90")
}
// Stop program via the app's stop button
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment