The words change their character based on the “characters” surrounding them.
Things like asterisks, (*), hash marks, (#), and others can be “magic” and cause the formatting to change.
If you want to create a “block of unformatted text”, sometimes called a “code block”, you start it with three back-ticks, (```), on a line by themselves, and then add three more after the last line in your code block.
Let me snip your text and see what I can do with it:
I put three back-ticks before the “#!/usr/bin/python” part, and three more back-ticks on the line directly after the “brickpi3.SensorError: get_sensor error: Invalid sensor data” line.
Another formatting tip:
If you want to use a “magical” character, (things like “#”, “&”, “*”, “`”, (or others I don’t remember), as actual printable characters you must “escape” them with the “backslash” (\). In order to show the backslash, I have to type it twice (\\) so that it “escapes” itself and is shown.
So, now let’s look at that code. . .
class lego infrared sensor
Author: Th. Kaffka, Cologne, Germany
modifiziert von Andreas Ehrhard
BP = brickpi3.BrickPi3()
def init(self, port):
self.port = port
Which seems to result in:
Traceback (most recent call last):
File “/home/pi/Ae/Roboter/Modelle/13_StayOnTable/StayOnTable_Ehr.py”, line 75, in
dist = us.getDistance()
File “/home/pi/Ae/Roboter/Interface/NXTUltrasonicSensor.py”, line 74, in getDistance
File “/usr/local/lib/python3.5/dist-packages/brickpi3-0.0.0-py3.5.egg/brickpi3.py”, line 707, in get_sensor
raise SensorError(“get_sensor error: Invalid sensor data”)
brickpi3.SensorError: get_sensor error: Invalid sensor data
It is a school-Project. I’m an Informatik-Teacher and want to show how to use the old NXT-Hardware instead of throwing it away.
All I need is a Class for each Sensortype of the NXT-Education-Set.
On your homepage (see How To Program the LEGO Robot BrickPi3 in Python Programming Language) is written, that the NXT-Sensor are supported. That was one of the reasons to buy som BrickPi (3 at the moment) to test it.