# ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time import sys from pprint import pprint from cio import default_handle as h pprint(h.CAPS) t1 = h.acquire_component_interface('Timer1PWM') t1.set_top(40000) t1.set_ocr_a(3000) t1.enable_a() time.sleep(2) for i in range(2000, 4000, 10): t1.set_ocr_a(i) time.sleep(0.01) t1.set_ocr_a(3000) time.sleep(2)
# # Copyright (c) 2017-2018 AutoAuto, LLC # ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time from pprint import pprint from cio import default_handle as h pprint(h.CAPS) enc = h.acquire_component_interface('Encoders') enc.enable_e2() def fmt(val): return "{:6d}".format(val) while True: print(''.join([fmt(val) for val in enc.read_e2_counts()])) print() time.sleep(0.1) ### DRIVE THE CAR # from car import motors
############################################################################### # # Copyright (c) 2017-2018 AutoAuto, LLC # ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time from pprint import pprint from cio import default_handle as h pprint(h.CAPS) p = h.acquire_component_interface('Photoresistor') for i in range(1000): print(p.read(), p.read_millivolts(), p.read_ohms()) time.sleep(0.1)
############################################################################### # # Copyright (c) 2017-2018 AutoAuto, LLC # ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time from pprint import pprint from cio import default_handle as h pprint(h.CAPS) b = h.acquire_component_interface('PushButtons') while True: events = b.get_events() for e in events: pprint(e) time.sleep(0.5)
############################################################################### # # Copyright (c) 2017-2018 AutoAuto, LLC # ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time from pprint import pprint from cio import default_handle as h pprint(h.CAPS) version = h.acquire_component_interface('VersionInfo') print(version.version())
############################################################################### # # Copyright (c) 2017-2018 AutoAuto, LLC # ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time from pprint import pprint from cio import default_handle as h pprint(h.CAPS) batt = h.acquire_component_interface('BatteryVoltageReader') while True: print(batt.millivolts()) time.sleep(0.1)
############################################################################### # # Copyright (c) 2017-2018 AutoAuto, LLC # ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time from pprint import pprint from cio import default_handle as h pprint(h.CAPS) gyro = h.acquire_component_interface('Gyroscope') gyro_accum = h.acquire_component_interface('Gyroscope_accum') for i in range(1000): print(gyro.read()) print(gyro_accum.read()) print() time.sleep(0.1)
############################################################################### # # Copyright (c) 2017-2018 AutoAuto, LLC # ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time from pprint import pprint from cio import default_handle as h pprint(h.CAPS) calibrator = h.acquire_component_interface('Calibrator') calibrator.calibrate()
# # Copyright (c) 2017-2018 AutoAuto, LLC # ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time from pprint import pprint from cio import default_handle as h pprint(h.CAPS) motors = h.acquire_component_interface('CarMotors') motors.set_params( top=40000, steering_left=3600, steering_mid=3000, steering_right=2400, steering_millis=1000, throttle_forward=4000, throttle_mid=3000, throttle_reverse=2000, throttle_millis=1000, ) motors.save_params() motors.on()
############################################################################### # # Copyright (c) 2017-2018 AutoAuto, LLC # ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time from pprint import pprint from cio import default_handle as h pprint(h.CAPS) b = h.acquire_component_interface('Buzzer') time.sleep(2) #b.play() # defaults to the 'on' sound #b.play('o4l16ceg>c8') # the 'on' sound (explicit this time) #b.play('v10>>g16>>>c16') # the soft reset sound #b.play('>E>E>E R >C>E>G') #b.play('!L16 V12 cdefgab>cbagfedc') # C-major scale up and down b.play('!T240 L8 agafaea dac+adaea fa<aa<bac#a dac#adaea f4' ) # "Bach's fugue in D-minor" time.sleep(5)
# # Copyright (c) 2017-2018 AutoAuto, LLC # ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time from pprint import pprint from cio import default_handle as h pprint(h.CAPS) loop = h.acquire_component_interface('LoopFrequency') for i in range(50): print(loop.read()) time.sleep(0.05) gyro = h.acquire_component_interface('Gyroscope') for i in range(50): print(loop.read()) time.sleep(0.05) accel = h.acquire_component_interface('Accelerometer') for i in range(50): print(loop.read())
############################################################################### # # Copyright (c) 2017-2018 AutoAuto, LLC # ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time from pprint import pprint from cio import default_handle as h pprint(h.CAPS) accel = h.acquire_component_interface('Accelerometer') for i in range(1000): print(accel.read()) time.sleep(0.1)
# # Copyright (c) 2017-2018 AutoAuto, LLC # ALL RIGHTS RESERVED # # Use of this library, in source or binary form, is prohibited without written # approval from AutoAuto, LLC. # ############################################################################### import time from pprint import pprint from cio import default_handle as h pprint(h.CAPS) leds = h.acquire_component_interface('LEDs') leds.set_mode(1) time.sleep(3) leds.set_mode(0) leds.set_values() time.sleep(1) for i in range(8): binary = "{0:{fill}3b}".format(i, fill='0') red, green, blue = [int(b) for b in binary] leds.set_values(red, green, blue) time.sleep(1)