Created
January 2, 2017 22:40
-
-
Save attilavago/1a0c14eb5654a56c6c7973626f309594 to your computer and use it in GitHub Desktop.
This test demonstrates getting the tilt value from a gyro sensor
This file contains 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
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