Skip to content

Sensors

Mr. James edited this page Sep 9, 2020 · 5 revisions

Senors

Expansion Pins

Image of the speaker's location

p1 ---------------------------

Reads the P1's S pin and sends the value back. This is an analog pin and the value that is read will be between 0 and 65535. This range can be converted to volts. Visit Adafruit's Circuitpython Essentials guide to learn more.

Parameters:

None

Examples:

pvalue = cutebot.p1      # sets the variable pvalue equal to value of P1's S pin at that moment
print(cutebot.p1)        # prints the value of P1's _S_ pin at that moment

p2 ---------------------------

Reads the P2's S pin and sends the value back. This is an analog pin and the value that is read will be between 0 and 65535. This range can be converted to volts. Visit Adafruit's Circuitpython Essentials guide to learn more.

Parameters:

None

Examples:

pvalue = cutebot.p2      # sets the variable pvalue equal to value of P2's S pin at that moment
print(cutebot.p2)        # prints the value of P2's S pin at that moment

Sonar

Image of the speaker's location

sonar ---------------------------

Emits a pulse and times how long it takes to hear it bounce back. The value that is returned is in centimeters (cm).

Parameters:

None

Examples:

pvalue = cutebot.sonar      # sets the variable pvalue equal to distance at that moment
print(cutebot.sonar)        # prints the distance at that moment

Line Tracking

Image of the speaker's location

tracking ---------------------------

Reads the line tracking senors and returns two values. One for each sensor: left and right. The values returned are either True when the sensor over very dark color or False when over a very light color.

Parameters:

None

Examples:

leftd, rightd = cutebot.tracking      # sets the variable leftd and rightd equal to sensors states at that moment
print(cutebot.tracking)               # prints the sensors states at that moment