-
Notifications
You must be signed in to change notification settings - Fork 0
Sensors
johnmeshulam edited this page Nov 10, 2019
·
3 revisions
FLL-leJOS has 4 sensor types:
- Gyro
- Touch
- Color
- Ultrasonic
To define a new sensor, write the following in HardwareCreator:
new <SensorType>(String name, int port);
Examples:
new GyroSensor("myGyro", 1);
new TouchSensor("myTouchSensor", 3);To access a sensor, call RobotMap.getSensor() with either the name or port:
RobotMap.getSensor("myGyro")
RobotMap.getMotor(3)This will allow you to use the sensor as follows:
RobotMap.getSensor(3).read();Sensors have one primary function: read() read() returns a double containing the current sensor value.
Sensors can have their current value defined as 0 with resetToCurrentValue(), and return their original definition of 0 with resetToAbsoluteValue()
Gyro sensors can also calibrate with the calibrate() function
- Overview
- Code Documentation
- Writing our first run
- Setting Up
- Defining hardware
- Writing a basic Motor Control run
- [Adding sensors and waits]
- [Defining Runs]
- Writing our second run
- [Using the chassis]
- [Finishing up]
- [Line follower code example]