0% found this document useful (0 votes)
23 views3 pages

Python Quick Reference

The document is a Python Quick Reference Guide covering autonomous motors, drivetrain, sensors, and Bluetooth control. It includes sample code for motor control, speed settings, and sensor usage for tasks like line following and distance measurement. Additionally, it provides examples for Bluetooth control using Pestolink, including setting up the robot name and controlling servos with button inputs.

Uploaded by

Maxi Rodriguez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views3 pages

Python Quick Reference

The document is a Python Quick Reference Guide covering autonomous motors, drivetrain, sensors, and Bluetooth control. It includes sample code for motor control, speed settings, and sensor usage for tasks like line following and distance measurement. Additionally, it provides examples for Bluetooth control using Pestolink, including setting up the robot name and controlling servos with button inputs.

Uploaded by

Maxi Rodriguez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Quick Reference Guide

Autonomous Motors and Drivetrain

Sample code for running a left motor with


.75 power. Should be a value of 0 to 1.

Sets up an additional encoded motor in


port 3. Runs the motor at .75 power.

Uses a sleep timer to run the motor for 5


seconds before setting power to 0.

Sets the speed of motor 1 to 60 RPM


using encoders.

Uses an encoded motor and PID control


to set speed to 60 RPM.

Use the drivetrain motors to go straight


with a speed of 10 and .5 effort.

Allows for the use of two different effort


values in the drivetrain with the motors
running for 5 seconds before stopping.

Sets the drivetrain speed to 5 RPM for 3


seconds.

Allows you to use the drivetrain to turn to


a specific degree with .5 power with
1-second sleep in between.
Python Quick Reference Guide

Sensors and Servos

Using the rangefinder, the robot will drive


while the distance is greater than 10.

Uses the reflectance sensors and PID control


to have the robot run and follow the line using
differential drive.

For a count of 10, the robot will rotate through


angles from 0 to 135
Python Quick Reference Guide

Pestolink Bluetooth Control Example

Imports the necessary modules for the


program to run.

This is where you should change the robot


name that will show up in the Bluetooth
option.

Gets the axis from the Pestolink webpage


and associates it with arcade drive using
throttle and rotation. get_axis(0) is the Y axis
and get_axis(1) is the X axis.

Sets the servo angle when button 0 is


pressed. Note there are many other button
options that could be utilized in programming.

You might also like