|
Revision 8, 0.8 kB
(checked in by Jan-Klaas Kollhof, 3 years ago)
|
|
updated SVN keywords
|
-
Property svn:executable set to
*
-
Property svn:keywords set to
Date Author LastChangedDate
|
| Line | |
|---|
| 1 | #!/usr/bin/env python |
|---|
| 2 | """ |
|---|
| 3 | Simple script to display sensor values. |
|---|
| 4 | |
|---|
| 5 | author: Jan-Klaas Kollhof |
|---|
| 6 | last changed by: $LastChangedBy$ |
|---|
| 7 | last changed date: $Date$ |
|---|
| 8 | revision: $Revision$ |
|---|
| 9 | """ |
|---|
| 10 | |
|---|
| 11 | import nxt.locator |
|---|
| 12 | from nxt.sensor import * |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | def displaySensors(): |
|---|
| 16 | sock = nxt.locator.find_one_brick() |
|---|
| 17 | brick = sock.connect() |
|---|
| 18 | |
|---|
| 19 | touch = TouchSensor(brick, PORT_1) |
|---|
| 20 | sound = SoundSensor(brick, PORT_2) |
|---|
| 21 | light = LightSensor(brick, PORT_3) |
|---|
| 22 | sonic = UltrasonicSensor(brick, PORT_4) |
|---|
| 23 | try: |
|---|
| 24 | while True: |
|---|
| 25 | values = (touch.get_sample(), sound.get_sample(), light.get_sample(), sonic.get_sample()) |
|---|
| 26 | print "touch:%s sound: %03d light:%03d sonic:%03d" % values |
|---|
| 27 | except: |
|---|
| 28 | pass |
|---|
| 29 | finally: |
|---|
| 30 | sock.close() |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | if __name__ == "__main__": |
|---|
| 34 | displaySensors() |
|---|