Skip to content

Commit

Permalink
Merge pull request #27 from IDATT1004-Team13-H2025/ny-sensor-implemen…
Browse files Browse the repository at this point in the history
…tasjon

Sensor bibliotek implementert
  • Loading branch information
robinsp authored Oct 29, 2025
2 parents 2b69abe + 234c168 commit 1532ec7
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions py/src/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,48 @@
from pybricks.robotics import DriveBase
from pybricks.media.ev3dev import SoundFile, ImageFile

from pybricks.nxtdevices import TemperatureSensor

"""
GAMMEL SENSOR FUNKSJONALITET
BEHOLDES FREM TIL NY FUNKSJONALITET ER IMPLEMENTERT
"""
class Sensors():
def __init__(self, sensors: tuple):

self.color, self.ultrasonic = sensors




"""
NY SENSOR FUNKSJONALITET
"""
class UltraSonic():
def __init__(self, sensorPort):
self.sensor = UltrasonicSensor(port=sensorPort)

def distanceLessThan(self, value):
if self.sensor.distance() < value:
return True
else:
return False


class Color():
def __init__(self, sensorPort):
self.sensor = ColorSensor(port=sensorPort)

def reflectionGreaterThan(self, value):
if self.sensor.reflection() > value:
return True
else:
return False

class Temperature():
def __init__(self, sensorPort):
self.sensor = TemperatureSensor(port=sensorPort)

def temperatureGreaterThan(self, value):
if self.sensor.temperature > value:
return True
else:
return False

0 comments on commit 1532ec7

Please sign in to comment.