Vernier Acceleration Sensor Python: Difference between revisions
From wikiluntti
No edit summary |
|||
Line 1: | Line 1: | ||
=== Introduction === | === Introduction === | ||
=== | === Sensor Class: Check the modes === | ||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
Line 30: | Line 30: | ||
Not working. | Not working. | ||
=== Sensor class === | |||
<syntaxhighlight lang="python"> | |||
from ev3dev2.sensor import * | |||
import time | |||
accSensor = Sensor(address="ev3-ports:in1") | |||
print( accSensor ) | |||
print( accSensor.modes ) | |||
#time.sleep(5) | |||
accSensor.mode="REF-RAW" #about 565, no changes | |||
#accSensor.mode="RGB-RAW" #about 121 | |||
#accSensor.mode="COL-CAL" #Not working | |||
#time.sleep(5) | |||
while 1: | |||
print(accSensor.value() ) | |||
</syntaxhighlight> |
Revision as of 19:45, 21 September 2020
Introduction
Sensor Class: Check the modes
#!/usr/bin/env python3
# https://sites.google.com/site/ev3devpython/
from ev3dev2.sensor import *
from ev3dev2.sensor import INPUT_1
import time
p = Sensor( INPUT_1 )
while 1:
print( p.modes )
time.sleep(5)
Returns the following modes 'ref-raw', 'rgb-raw' and 'col-cal'
REF-RAW
Not working.
RGB-RAW
Not working.
COL-CAL
Not working.
Sensor class
from ev3dev2.sensor import *
import time
accSensor = Sensor(address="ev3-ports:in1")
print( accSensor )
print( accSensor.modes )
#time.sleep(5)
accSensor.mode="REF-RAW" #about 565, no changes
#accSensor.mode="RGB-RAW" #about 121
#accSensor.mode="COL-CAL" #Not working
#time.sleep(5)
while 1:
print(accSensor.value() )