def test_Led(): led = Led() try: #Red wipe print("\nRed wipe") led.colorWipe(led.strip, Color(255, 0, 0)) time.sleep(1) #Green wipe print("\nGreen wipe") led.colorWipe(led.strip, Color(0, 255, 0)) time.sleep(1) #Blue wipe print("\nBlue wipe") led.colorWipe(led.strip, Color(0, 0, 255)) time.sleep(1) #White wipe print("\nWhite wipe") led.colorWipe(led.strip, Color(255, 255, 255)) time.sleep(1) led.colorWipe(led.strip, Color(0, 0, 0)) #turn off the light print("\nEnd of program") except KeyboardInterrupt: led.colorWipe(led.strip, Color(0, 0, 0)) #turn off the light print("\nEnd of program")
def __init__(self, gpio, pin, ledPin): # initialize class variables self.gpio = gpio self.pir = pin self.led = Led.Led(gpio, ledPin) self.led.setup()
def __init__(self): self.tcp_flag = False self.led = Led() self.adc = ADS7830() self.servo = Servo() self.buzzer = Buzzer() self.control = Control() self.sonic = Ultrasonic() self.control.Thread_conditiona.start()
def __init__(self): self.PWM = Motor() self.servo = Servo() self.led = Led() self.ultrasonic = Ultrasonic() self.buzzer = Buzzer() self.adc = Adc() self.light = Light() self.infrared = Line_Tracking() self.tcp_Flag = True self.sonic = False self.Light = False self.Mode = 'one' self.endChar = '\n' self.intervalChar = '#'
def __init__(self): self.headUpDownAngle = 90 self.headLeftRightAngle = 90 self.PWM = Motor() self.servo = Servo() self.horn = Buzzer() self.speed = 1000 # corrected servo positions # adjust these to suit your car # so head is front and centre at start self.headLRcorrect = -3 self.headUDcorrect = 4 self.reset_head() self.selector = DefaultSelector() # set true for mecanum wheels self.mecanum = False self.useLights = True self.led = Led() self.mouse = evdev.InputDevice('/dev/input/event1') self.keybd = evdev.InputDevice('/dev/input/event0') self.readingKeys = False self.led.colorWipe(self.led.strip, Color(0,0,0),0) self.brake = False self.reverse = False self.indicating = False self.leftTurn = False self.rightTurn = False self.moving = False self.indi_time = datetime.now() self.indi_off = True self.brake_time = datetime.now() self.brake_off = True atexit.register(self.keybd.ungrab) # Don't forget to ungrab the keyboard on exit! atexit.register(self.mouse.ungrab) self.keybd.grab() # Grab, i.e. prevent the keyboard from emitting original events.# self.mouse.grab() # This works because InputDevice has a `fileno()` method. self.selector.register(self.mouse, EVENT_READ) self.selector.register(self.keybd, EVENT_READ)
import time from Led import * from servo import * from Motor import * led = Led() def test_Led(): try: led.ledIndex(0x01, 255, 0, 0) #Red led.ledIndex(0x02, 255, 125, 0) #orange led.ledIndex(0x04, 255, 255, 0) #yellow led.ledIndex(0x08, 0, 255, 0) #green led.ledIndex(0x10, 0, 255, 255) #cyan-blue led.ledIndex(0x20, 0, 0, 255) #blue led.ledIndex(0x40, 128, 0, 128) #purple led.ledIndex(0x80, 255, 255, 255) #white''' print "The LED has been lit, the color is red orange yellow green cyan-blue blue white" time.sleep(3) #wait 3s led.colorWipe(led.strip, Color(0, 0, 0)) #turn off the light print "\nEnd of program" except KeyboardInterrupt: led.colorWipe(led.strip, Color(0, 0, 0)) #turn off the light print "\nEnd of program" PWM = Motor() def test_Motor():
def __init__(self): self.led = Led()
import CmdMessenger import CmdManager import Motors import Gripper import Led import SpeedControl if __name__ == '__main__': cMes = CmdMessenger.CmdMessenger() cMes.start() cMan = CmdManager.CmdManager(cMes) cMotor = Motors.Motors(cMes, 5) cMotor.start() cSpeed = SpeedControl.SpeedControl(cMotor) gripper = Gripper.Gripper(cMes) led = Led.Led(cMes)
def Run_Cart4(self): #------------------------------------------Ultrasonic sensor and Servo Motor Class self.Ultrasonic = Ultrasonic() self.LED = Led() self.Buzzer = Buzzer() self.Junction = 0 #-------------------------------------------------------------------------------------- while True: self.Movement_Type = 0 Distance = self.Ultrasonic.get_distance() IR_Left = GPIO.input(IR01) IR_Mid = GPIO.input(IR02) IR_Right = GPIO.input(IR03) if (Distance > 15.0): if ((IR_Left == 0) and (IR_Mid == 1) and (IR_Right == 0)): if (self.Moved_Reverse_New != self.Moved_Reverse_Old): self.Movement_Type = 11 #Move Reverse else: self.Movement_Type = 5 #Move Forward self.Junction = 0 #Clear the Junction Variable elif ((IR_Left == 1) and (IR_Mid == 0) and (IR_Right == 0)): self.Movement_Type = 3 #Take Slight Left elif ((IR_Left == 1) and (IR_Mid == 1) and (IR_Right == 0)): self.Movement_Type = 3 #Take Slight Left elif ((IR_Left == 0) and (IR_Mid == 0) and (IR_Right == 1)): self.Movement_Type = 7 #Take Slight Right elif ((IR_Left == 0) and (IR_Mid == 1) and (IR_Right == 1)): self.Movement_Type = 7 #Take Slight Right elif ((IR_Mid == 1) and (IR_Left == 1) and (IR_Right == 1)): if (self.Junction == 0): self.Movement_Type = self.Mov_According_To_Specified_position( ) self.Junction = 1 else: pass else: self.Movement_Type = 0 #Stop Movement self.LED.ledIndex(0x20, 255, 125, 0) #Orange self.LED.ledIndex(0x40, 255, 125, 0) #Orange time.sleep(1) self.LED.ledIndex(0x60, 0, 0, 0) #Actuate the motors to move cart to the specific Coordinate self.Move_Cart(self.Movement_Type) if (self.Is_Intermediate_DestinTion_Reached()): break
test_images = [ ('01.jpg', [ 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0 ]), ('02.jpg', [1, 1, 1, 0, 1, 1, 0, 0]), # is tail 0,0 or 0,0,1? ('03.jpg', [0, 1, 1, 1, 0, 1, 1]), ('04.jpg', [1, 1, 0, 1, 1, 0, 0, 1]) ] start_time = time.time() print 'Slow algorithm' for test_image in test_images: image_original = cv2.imread('img_in' + os.sep + test_image[0]) led = ll.Led(image_original) counted_array = led.getCode() if cmp(counted_array, test_image[1]) != 0: print 'Error in decoding {}:'.format(test_image[0]) print 'correct:', test_image[1] print 'counted:', counted_array else: print test_image[0] + ' is correct!' print("--- %s seconds ---" % (time.time() - start_time)) # test fast method start_time = time.time() print '\nFast algorithm' for test_image in test_images: img_gray = cv2.imread('img_in' + os.sep + test_image[0], 0) counted_array = ll.Led.getCodeFast(img_gray)
def __init__(self): print("start main") self.green_led = Led(GREEN) self.yellow_led = Led(YELLOW) self.red_led = Led(RED) self.detected = False
def __init__(self): self.led = Led.Led() self.player = Player2.Player() self.btManager = BluetoothManager.BluetoothManager( self.onConnect, self.onDisconnect, self.player.on_property_changed) self.apds = Apds.Apds()
print('Initialize motor control...') myEngine = Motor.Motor() print('Initialize servo control ... ') myServo = ServoControl(debug = True) print('Initialize Buzzer Driver...') myBuzzer = Buzzer.Buzzer() print('Initialize ADC Driver...') myAdc = ADC.Adc() Thread_Monitor = threading.Thread(target = monitorBattery, args=[myAdc, myBuzzer]) Thread_Monitor.start() print('Initialize LED Driver...') myLed = Led.Led() try: print('Center camera head...') myServo.center() time.sleep(2) print('Enter 50ms control loop...') disableMotor = False while True: # 1st stick controls the wheel motors stick1_hor = myPad.get_axis_scaled(0) stick1_ver = myPad.get_axis_scaled(1) if not disableMotor: process_stick1(stick1_hor, stick1_ver, myEngine) else: