#!/usr/bin/env python3
from time import sleep
from ev3dev2.sensor import INPUT_1, INPUT_2, INPUT_3, INPUT_4
from ev3dev2.port import LegoPort
from ev3dev2.sensor.lego import UltrasonicSensor

# Input 1 = color sensor
# Input 2 = nxt ultrasonic
# Input 3 = button
# Input 4 = infrared

p2 = LegoPort(INPUT_2)
p2.mode = 'nxt-i2c'

sleep(0.5)

us = UltrasonicSensor(INPUT_2)

us.mode = us.MODE_US_DIST_CM
while True:
  print(us.distance_centimeters)
  sleep(1)


#!/usr/bin/env python3
from time import sleep
from ev3dev2.sensor import INPUT_1, INPUT_2, INPUT_3, INPUT_4
from ev3dev2.port import LegoPort
from ev3dev2.sensor.lego import UltrasonicSensor

# Input 1 = color sensor
# Input 2 = nxt ultrasonic
# Input 3 = button
# Input 4 = infrared

p2 = LegoPort(INPUT_2)
p2.mode = 'nxt-i2c'

sleep(0.5)

us = UltrasonicSensor(INPUT_2)

us.mode = us.MODE_US_DIST_CM
while True:
  print(us.distance_centimeters)
  sleep(1)


#!/usr/bin/env python3 # Input 1 = color sensor # Input 2 = nxt ultrasonic # Input 3 = button # Input 4 = infrared