This page will help you get started with Marty's distance sensor add on using the python library. Before we get started, make sure you have [[:martyv2:userguides:python:start|python installed]] and [[:martyv2:userguides:sensorsandaddons:distancesensor|have set up your distance sensor]]. ===== Step 1 ===== Import martypy and establish connection to your Marty. Follow the code below to connect your Marty. import martypy # USB connection # change "COM1" on this next line to specify the USB port you want to use # comment this line out to use WiFi my_marty = martypy.Marty("USB") # WiFi connection # uncomment this and change the IP address to your Marty's to use WiFi # my_marty = martypy.Marty("wifi", "192.168.0.5") You should now be able to play with your distance sensor using the function below. =====Let's Code!===== The function //**get_distance_sensor()**// returns an integer of the distance of the closest object (in mm). Try this function using the code below: my_marty.get_distance_sensor()