pwmSlew = pyb.Pin('X2') pwmBias = pyb.Pin('X3') tim2 = pyb.Timer(2, freq=10000) tim5 = pyb.Timer(5, freq=10000) pwmGainCh = tim5.channel(1, pyb.Timer.PWM, pin=pwmGain) pwmBiasCh = tim5.channel(2, pyb.Timer.PWM, pin=pwmBias) pwmBiasCh.pulse_width_percent(50) pwmSlewCh = tim2.channel(1, pyb.Timer.PWM, pin=pwmSlew) amplitude, Stop = 999, True frequency = 10000 duty = 25 while Stop: cmd = usb.recv(4, timeout=5000) usb.write(cmd) if (cmd == b'strt'): pyb.LED(1).on() pyb.LED(2).off() pyb.LED(3).off() utime.sleep(1) tim2 = pyb.Timer(2, freq=5000) pwmSlewCh.pulse_width_percent(duty) elif (cmd == b'ampl'): data1 = bytes(8) cmd = usb.recv(4, timeout=5000) data1 = ustruct.unpack('L', cmd) dataList1 = list(data1) dataStr1 = [str(i) for i in dataList1] percent = int("".join(dataStr1)) usb.write(ustruct.pack('L', percent)) pwmGainCh.pulse_width_percent(percent) elif (cmd == b'slew'):
# use colors to annoy people during testing RED_LED_PIN = 1 GREEN_LED_PIN = 2 BLUE_LED_PIN = 3 # define a list of blindness times blindness_array = [ 10, 50, 100, 250, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 5000, 9999 ] blindness_array.reverse() # go largest to smallest # loop through all blindness times for blindness_time in blindness_array: # flash light to signal camera activation pyb.LED(BLUE_LED_PIN).on() # print message to serial monitor print("Testing blindness for: %4d ms" % blindness_time) # instantaneously make the computer shut its eye sensor.sleep(True) sensor.sleep(False) # initialize camera and define camera settings sensor.reset() # initialize the camera sensor sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE sensor.set_framesize(sensor.VGA) # or sensor.QVGA (or others) sensor.skip_frames( time=blindness_time) # let new settings take effect ("be blind")
def isr_speed_timer(self, t): self.speedA = self.countA self.speedB = self.countB self.countA = 0 self.countB = 0 pyb.LED(3).toggle()
import time, sensor, image, pyb from image import SEARCH_EX, SEARCH_DS from pyb import Pin, Timer from pyb import UART uart = UART(3, 115200) led = pyb.LED(1) led2 = pyb.LED(2) led3 = pyb.LED(3) thresholds = (0, 45) sensor.reset() sensor.set_framesize(sensor.QQVGA) sensor.set_pixformat(sensor.GRAYSCALE) sensor.skip_frames(time = 1000) HA = image.Image("/exampleHF1.pgm") HB = image.Image("/exampleHF2.pgm") HC = image.Image("/exampleHF3.pgm") SA = image.Image("/exampleSF1.pgm") SB = image.Image("/exampleSF2.pgm") SC = image.Image("/exampleSF3.pgm") UA = image.Image("/exampleUF1.pgm") tim = Timer(4, freq=1000) clock = time.clock() led.on()
#2018.8.2 import sensor, image, time , pyb from pyb import UART from pyb import Timer from pyb import LED import json led = pyb.LED(3) # Red LED = 1, Green LED = 2, Blue LED = 3, IR LEDs = 4. thresholds = [(27, 67, 19, 91, 45, 76), # 红色 #(21, 75, 3, -38, 34, 68), # 绿色 (27, 90, -3, -28, 31, 125), (0, 30, 0, 64, -128, 0)] # generic_blue_thresholds threshold_index = 1 # 0 for red, 1 for gre9en, 2 for blue sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) #320*240 sensor.skip_frames(time = 100) sensor.set_auto_gain(False) # must be turned off for color tracking sensor.set_auto_whitebal(False) # must be turned off for color tracking clock = time.clock() uart = UART(3, 115200) uart.init(115200, bits=8, parity=None, stop=1, timeout_char=1000) # 使用给定参数初始化 def tick(timer): # we will receive the timer object when being called global data if blobs: print("Find") print('you send:',output_str) uart.write(data)
import sensor, image, time, gif, pyb, os RED_LED_PIN = 1 BLUE_LED_PIN = 3 sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE sensor.set_framesize(sensor.QQVGA) # or sensor.QVGA (or others) sensor.skip_frames(10) # Let new settings take affect. sensor.set_whitebal(False) # Turn off white balance. if not "temp" in os.listdir(): os.mkdir("temp") # Make a temp directory while (True): pyb.LED(RED_LED_PIN).on() print("About to save background image...") sensor.skip_frames(60) # Give the user time to get ready. pyb.LED(RED_LED_PIN).off() sensor.snapshot().save("temp/bg.bmp") print("Saved background image - Now detecting motion!") pyb.LED(BLUE_LED_PIN).on() diff = 10 # We'll say we detected motion after 10 frames of motion. while (diff): img = sensor.snapshot() img.difference("temp/bg.bmp") for blob_l in img.find_blobs([(20, 100, -128, 127, -128, 127)]): for blob in blob_l: # Over 100 pixels need to change to detect motion.
uart = UART(3, baudrate=9600) accel = pyb.Accel() #Servo Initialization Sep_Servo = pyb.Servo(1) Stabil_Servo = pyb.Servo(2) orientServo = pyb.Servo(3) Table_Servo = pyb.Servo(4) p = Pin('X6') tim = Timer(8, freq=50) ArmDep_Servo = tim.channel(1, Timer.PWM, pin=p) #Limit switch and LED initialization Sep_SW = Pin('Y12', Pin.IN, Pin.PULL_UP) Table_SW = Pin('Y11', Pin.IN, Pin.PULL_UP) R_led = pyb.LED(1) G_led = pyb.LED(2) O_led = pyb.LED(3) B_led = pyb.LED(4) #Constants Definition for Orientation CW = 99 CCW = 99 #Make both directions the same value. We don't care to rotate in two directions. #CCW = -99 #Uncomment this to add a second direction for possible rotation. Stop = 0 #Timers for the deployment process Sep_Limit = 60 + 60 + 30 #2 min 30 seconds Stabil_Limit = 12 #12 seconds ArmDep_Limit = 1 * 5 * .5 #This was arbitrarily chosen, need to update when completed
from pyb import Timer import micropython #Import light intensity needed module import LightIntensity import time micropython.alloc_emergency_exception_buf(100) print('pin init') Pin('Y11', Pin.OUT_PP).low() #GND Pin('Y9', Pin.OUT_PP).high() #VCC #LED shining regularly(using timer) to indicate the program is running correctly tim1 = Timer(1, freq=1) tim1.callback(lambda t: pyb.LED(1).toggle()) if __name__ == '__main__': while True: print('Smart IoT Plant System-Device') print(LightIntensity.readLight()) time.sleep(2) #send on-line message to gateway to notifiy and obtain own data from gateway's database ###reference begin### """ import pyb from pyb import Pin from ds18x20 import DS18X20 from pyb import Timer
# Sleep Buffer # 0 None OK, length limit 74 # 10 None Bad: length 111 also short weird RMC sentences # 10 1000 OK, length 74, 37 # 10 200 Bad: 100, 37 overruns # 10 400 OK, 74,24 Short GSV sentence looked OK # 4 200 OK, 74,35 Emulate parse time # as_GPS.py # As written update blocks for 23.5ms parse for 3.8ms max # with CRC check removed update blocks 17.3ms max # CRC, bad char and line length removed update blocks 8.1ms max # At 10Hz update rate I doubt there's enough time to process the data BAUDRATE = 115200 red, green, yellow, blue = pyb.LED(1), pyb.LED(2), pyb.LED(3), pyb.LED(4) async def setup(): print('Initialising') uart = pyb.UART(4, 9600) sreader = asyncio.StreamReader(uart) swriter = asyncio.StreamWriter(uart, {}) gps = as_rwGPS.GPS(sreader, swriter, local_offset=1) await asyncio.sleep(2) await gps.baudrate(BAUDRATE) uart.init(BAUDRATE) def setbaud(): asyncio.run(setup()) print('Baudrate set to 115200.')
import pyb, micropython import time micropython.alloc_emergency_exception_buf(100) class Foo(object): def __init__(self, timer, led): self.led = led timer.callback(self.cb) def cb(self, tim): self.led.toggle() blue = Foo(pyb.Timer(2, freq=2), pyb.LED(1)) # LED(1) -> PE3 while True: time.sleep(1)
# log the accelerometer values to a .csv-file on the SD-card import pyb accel = pyb.Accel() # create object of accelerometer blue = pyb.LED(4) # create object of blue LED log = open( '1:/log.csv', 'w' ) # open file to write data - 1:/ ist the SD-card, 0:/ the internal memory blue.on() # turn on blue LED for i in range( 100 ): # do 100 times (if the board is connected via USB, you can't write longer because the PC tries to open the filesystem which messes up your file.) t = pyb.millis() # get time since reset x, y, z = accel.filtered_xyz() # get acceleration data log.write('{},{},{},{}\n'.format(t, x, y, z)) # write data to file log.close() # close file blue.off() # turn off LED
def __init__(self, led_index: int): self.led = pyb.LED(led_index)
''' Premier script : controle de LED ''' #import de la librairie import pyb #définition des led avec tableau leds = [pyb.LED(i) for i in range(1, 5)] for l in leds: l.off() #affichage de la led n = 0 try: while True: n = (n + 1) % 4 leds[n].toggle() pyb.delay(50) finally: for l in leds: l.off()
def __init__(self): self.tick = 0 self.led = pyb.LED(4) # 4 = Blue tim = pyb.Timer(4) tim.init(freq=10) tim.callback(self.heartbeat_cb)
def toggle_light_once(num): leds = [pyb.LED(i) for i in range(1, 5)] leds[num].off()
import pyb from pyb import Pin from access_control_upy.access_control_1_0 import Access_control_upy P_read_en1 = Pin('Y1', Pin.IN) P_read_en2 = Pin('Y2', Pin.IN) P_read_ex1 = Pin('Y3', Pin.IN) P_read_ex2 = Pin('Y4', Pin.IN) P_mag_en1 = pyb.LED(1)#Pin('X1', Pin.OUT_PP) P_mag_en2 = pyb.LED(2)#Pin('X1', Pin.OUT_PP) P_mag_ex1 = pyb.LED(3)#Pin('X1', Pin.OUT_PP) P_mag_en2 = pyb.LED(4)#Pin('X1', Pin.OUT_PP) MAGs = [P_mag_en1,P_mag_en2,P_mag_ex1,P_mag_ex2] mouse_in_training = None com = pyb.USB_VCP() state = 'allow_entry' while True:
def init_light(): leds = [pyb.LED(i) for i in range(1, 5)] for l in leds: l.off()
# color tracking - By: paolix - ven mag 18 2018 # Automatic RGB565 Color Tracking Example # import sensor, image, time, pyb, math from pyb import UART uart = UART(3, 19200, timeout_char=1000) # LED Setup ################################################################## red_led = pyb.LED(1) green_led = pyb.LED(2) blue_led = pyb.LED(3) red_led.off() green_led.off() blue_led.on() ############################################################################## #thresholds = [ (30, 100, 15, 127, 15, 127), # generic_red_thresholds # (30, 100, -64, -8, -32, 32), # generic_green_thresholds # (0, 15, 0, 40, -80, -20)] # generic_blue_thresholds #thresholds = [ (54, 93, -10, 25, 55, 70), # thresholds yellow goal # (30, 45, 1, 40, -60, -19)] # thresholds blue goal # thresholds = [ (69, 99, -23, 17, 29, 101), # thresholds yellow goal (26, 65, -11, 47, -95, -36)
import pyb from pyb import UART from pyb import Pin M2 = Pin('X3', Pin.IN) M3 = Pin('X4', Pin.IN) N1 = Pin('Y1', Pin.OUT_PP) N2 = Pin('Y2', Pin.OUT_PP) N3 = Pin('Y3', Pin.OUT_PP) N4 = Pin('Y4', Pin.OUT_PP) u2 = UART(2, 9600) while True: pyb.LED(2).on() pyb.LED(3).on() pyb.LED(4).on() _dataRead = u2.readall() if _dataRead != None: #停止 if (_dataRead.find(b'\xa5Z\x04\xb1\xb5\xaa') > -1): print('stop') N1.low() N2.low() N3.low() N4.low() #向左 elif (_dataRead.find(b'\xa5Z\x04\xb4\xb8\xaa') > -1): print('left') N1.low() N2.high()
def f(): pyb.LED(1).toggle()
# Automatic RGB565 Color Tracking Example # # This example shows off single color automatic RGB565 color tracking using the OpenMV Cam. import sensor, image, time import pyb #print("Letting auto algorithms run. Don't put anything in front of the camera!") fmt = sensor.RGB565 res = sensor.QVGA led1 = pyb.LED(1) led2 = pyb.LED(2) file = open("camId.txt") cam = int(file.readline()) file.close() sensor.reset() sensor.set_pixformat(fmt) sensor.set_framesize(res) sensor.skip_frames(time=2000) sensor.set_auto_gain(False) # must be turned off for color tracking sensor.set_auto_whitebal(False) # must be turned off for color tracking clock = time.clock() startOfPacket = { "cam": cam, "time": pyb.elapsed_millis(0), "fmt": fmt, "height": sensor.height(), "width": sensor.width() } endOfPacket = {"end": 0}
def __init__(self, draw_stats=False, draw_lines=False, draw_lap_times=False, draw_timer=False, draw_line_stats=False, save_first_frame=False, flip_text=False, mirror_text=False, rotate_text=0, flip_travel_direction=False): # Setup hardware self.red_led = pyb.LED(1) self.green_led = pyb.LED(2) self.blue_led = pyb.LED(3) self.infra_led = pyb.LED(4) self.usb_serial = pyb.USB_VCP() # Serial Port # Auto gain and white balance settings #sensor.set_auto_gain(False) # must be turned off for color tracking #sensor.set_auto_whitebal(False) # must be turned off for color tracking # Set line finding parameters self.min_degree = 45 self.max_degree = 135 self.threshold = 1000 self.theta_margin = 25 # Max angle of lines to be merged and considered one self.rho_margin = 25 # Max spacing between lines along the rho axis self.x_stride = 2 self.y_stride = 8 # Configure IO pins for signaling self.action_pin = pyb.Pin('P7', pyb.Pin.OUT_OD, pyb.Pin.PULL_NONE) self.page_pin = pyb.Pin('P8', pyb.Pin.OUT_OD, pyb.Pin.PULL_NONE) self.lap_pin = pyb.Pin('P9', pyb.Pin.OUT_OD, pyb.Pin.PULL_NONE) # Configure the imaging sensor sensor.reset() # Initialize the sensor sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format sensor.set_framesize(sensor.QQQVGA) # Set frame size sensor.set_auto_exposure(True, exposure_us=5000) # Smaller means faster sensor.skip_frames(time=2000) # Wait for settings take effect # Delta value in pixels for x/y for tracking new lines self.line_id_max_delta = 40 # Max frames without a line before line history is cleared self.frames_before_line_purge = 200 # should be inverse -> sensor.get_exposure_us / 25 # Default travel direction is from top to bottom self.flip_travel_direction = flip_travel_direction # Configure clock for tracking FPS self.clock = time.clock() # Configure the lcd screen. lcd.init() # Initialize image buffer self.img = sensor.snapshot() #Allocate memory for exceptions in async/timer driven code micropython.alloc_emergency_exception_buf(100) # Debugging only # Allocation for interrupt callbacks self._timer = pyb.Timer(13) self._timer.init(freq=10) self._timer.callback(self._cb) self._render_ref = self.render self._pin_reset_ref = self.pin_reset # Scale, sensor to screen self.scale = 1.5 # Show performance/debug statistics/info self.draw_stats = draw_stats self.draw_lines = draw_lines self.draw_lap_times = draw_lap_times self.draw_timer = draw_timer self.draw_line_stats = draw_line_stats self.line_draw_color = (255, 0, 0) self._fps = None self._known_lines = [] self._lap_timestamp = None self.lap_timestamps = [] self._lap_notification_timestamp = None self.lap_notification_timeout = 5000 self.save_first_frame = save_first_frame self.flip_text = flip_text self.mirror_text = mirror_text self.rotate_text = rotate_text
#Setting RTC regs to actual time #i2c.mem_write(0x00,0x68,0, timeout=1000) #i2c.mem_write(0x04,0x68,1, timeout=1000) #i2c.mem_write(0x15,0x68,2, timeout=1000) #i2c.mem_write(0x03,0x68,3, timeout=1000) #i2c.mem_write(0x17,0x68,4, timeout=1000) #i2c.mem_write(0x05,0x68,5, timeout=1000) #i2c.mem_write(0x19,0x68,6, timeout=1000) sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat( sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE) sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240) sensor.skip_frames(time=2000) # Wait for settings take effect. clock = time.clock() # Create a clock object to track the FPS. ir_leds = pyb.LED(4) ir_leds.on() print(i2c.is_ready(0x68)) #test=BCD() p = pyb.Pin("P6", pyb.Pin.OUT_PP) #p=pyb.Pin("P3", pyb.Pin.IN, pyb.Pin.PULL_DOWN) p.high() while (True): #strDateTime = "" #arrDateTime = [8]*7 #for i in range (0,7): #if i != 3: ##read the full data from RTC address #readFirst = (i2c.mem_read(1, 0x68, (6-i)))
def main(): start_time_lcg = utime.ticks_us() key_lcg = lcg(1140671485, 128201163, 2**24, pyb.rng(), 10) end_time_lcg = utime.ticks_us() totalTime_lcg = utime.ticks_diff(end_time_lcg, start_time_lcg) print("Time using LCG: {0} micoseconds".format(totalTime_lcg)) numberOfBit = 0 bkey = 0 r = xorshift(12, 25, 27) rand = [] start_time_XORShift = utime.ticks_us() for i in range(10): rand.append(r()) end__time_XORShift = utime.ticks_us() totalTime_XORShift = utime.ticks_diff(end__time_XORShift, start_time_XORShift) print("Time using XORShift: {0} micoseconds".format(totalTime_XORShift)) print("Time difference between LCG and XORShift : {0} microseconds".format( totalTime_lcg - totalTime_XORShift)) for j in rand: print("{0} using xorshift".format(j)) '''Change the LED color to check the key is randomized or not''' even = pyb.LED(4) odd = pyb.LED(3) '''Fast Exponentials''' print(fast_exp('10011', 3)) print(binpow(3, 19)) bitmesg = '0010010100011110011111110' #bitmesg = '0010010100011110011111110' key = '1011000101110010001110100' encM = encrypt(bitmesg, key) decryptM = decrypt(encM, key) if (encM == '1001010001101100010001010'): pyb.LED(2).on() if (decryptM == bitmesg): pyb.LED(3).on() deff() p = int(input("Enter a prime number (17, 19, 23, etc): ")) q = int(input("Enter another prime number (Not one you entered above): ")) if not (checkPrime(p)) and not (checkPrime(q)): print( "Both numbers are not prime. Please enter prime numbers only...\n") elif (not checkPrime(p)): print( "The first prime number you entered is not prime, please try again...\n" ) elif (not checkPrime(q)): print( "The second prime number you entered is not prime, please try again...\n" ) n = p * q '''===================================== =========== Euler Function =========== =====================================''' phin = (p - 1) * (q - 1) '''===================================== =========== Public key =========== =====================================''' e = 0 for i in range(3, phin): if (gcd(phin, i) == 1): e = i break #d = int(e+1); d = 0 for d in range(e + 1, n): if (((d * e) % phin) == 1): break mess = int(input("Enter some numerical data: ")) if (mess > n - 1): print( "Your message is too big. Please send another message or increase n ('p' and 'q')\n" ) cipher_rsa = powMod(mess, e, n) print("The cipher text is: {0}".format(cipher_rsa)) decrypt_rsa = powMod(cipher_rsa, d, n) print("The decrypted text is: {0}".format(decrypt_rsa)) for i in key_lcg: if (i % 2) == 0: print("{0} is Even".format(i)) bkey = destobin(i) numberOfBitinKey = bitCount(bkey) numberOfBitinMesg = bitCount(bitmesg) newbkey = sameSize(numberOfBitinKey, numberOfBitinMesg, bitmesg, bkey, "key") newbitmesg = sameSize(numberOfBitinKey, numberOfBitinMesg, bitmesg, bkey, "message") encM_lcg = encrypt(newbitmesg, newbkey) decryptM_lcg = decrypt(encM_lcg, newbkey) print("Number of bit in key = {0}".format(numberOfBitinKey)) print("Number of bit in Message = {0}".format(numberOfBitinMesg)) print("key = {0}".format(newbkey)) print("msg = {0}".format(newbitmesg)) print("encrypt = {0}".format(encM_lcg)) print("decrypt = {0}".format(decryptM_lcg)) x = int(newbitmesg) - int(decryptM_lcg) print("msg-decrypt = {0}".format(x)) even.toggle() pyb.delay(1000) even.toggle() else: print("{0} is Odd".format(i)) bkey = destobin(i) numberOfBitinKey = bitCount(bkey) numberOfBitinMesg = bitCount(bitmesg) newbkey = sameSize(numberOfBitinKey, numberOfBitinMesg, bitmesg, bkey, "key") newbitmesg = sameSize(numberOfBitinKey, numberOfBitinMesg, bitmesg, bkey, "message") encM_lcg = encrypt(newbitmesg, newbkey) decryptM_lcg = decrypt(encM_lcg, newbkey) print("Number of bit in key = {0}".format(numberOfBitinKey)) print("Number of bit in Message = {0}".format(numberOfBitinMesg)) print("key = {0}".format(newbkey)) print("msg = {0}".format(newbitmesg)) print("encrypt = {0}".format(encM)) print("decrypt = {0}".format(decryptM_lcg)) x = int(newbitmesg) - int(decryptM) print("msg-decrypt = {0}".format(x)) odd.toggle() pyb.delay(1000) odd.toggle() even.off() odd.off()
# main.py -- put your code here! import pyb led = pyb.LED(4) while True: led.toggle() pyb.delay(700)
rst = machine.Pin('PB1') # RST # Init LCD display lcd = pcd8544.PCD8544_FRAMEBUF(spi, cs, dc, rst) lcd.init() # Create object representing the USB virtual comm port obj = pyb.USB_VCP() while True: # Read all available bytes from the serial device buf = obj.read() if buf: # Turn on LED pyb.LED(1).on() # Refresh and init LCD display lcd = pcd8544.PCD8544_FRAMEBUF(spi, cs, dc, rst) lcd.init() # Decode data from the serial device text = str(buf.decode()) # Fill the entire FrameBuffer with the specified color lcd.fill(0) # Print data from the serial device on the screen lcd.text(text, 2, 1, 1) # Write data through SPI
def set_low_resolution(address): register = 0x03 config = i2c.readfrom_mem(address, register, 1) # bitwise operators can only operate on int types, not bytes types config_int = int.from_bytes(config, 'big') new_config = config_int & 0x7F new_config_bytes = new_config.to_bytes(1, 'big') i2c.writeto_mem(address, register, new_config_bytes) #--------------------------------------------------------- # Main code #--------------------------------------------------------- blue = pyb.LED(4) # LED object i2c = I2C('X', freq=100000) devices = i2c.scan() for i, device in enumerate(devices): set_high_resolution(device) print("I2C device {} at address: {}".format(i, hex(device))) max_count = 10 count = 0 start = pyb.millis() while count <= max_count: elapsed = pyb.elapsed_millis(start) blue.toggle()
def turnoff_light(num): leds = [pyb.LED(i) for i in range(1, 5)] leds[num].off()
# main.py -- put your code here! import pyb led = pyb.LED(1) #uart = pyb.UART(2, 9600) rtc = pyb.RTC() rtc.init() i2c_mfx = pyb.I2C(config['mfx']['i2c_bus'], pyb.I2C.MASTER, baudrate=100000) wake_up_mfx = pyb.Pin(config['mfx']['wakeUp_pin'], pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE) irq_mfx = pyb.Pin(config['mfx']['irq_pin'], pyb.Pin.IN, pyb.Pin.PULL_DOWN) conf = IDD_DEFAULT() mfx = MFX(i2c_mfx, config['mfx']['i2c_addr'], wake_up_mfx, conf, irq_mfx) idx=0 while True: led.toggle() data = None #uart.read(10) Y,M,D,wd,h,m,s,ms = rtc.datetime() dstr="Time: %d.%d.%d %02d:%02d:%02d\n\r" % (D,M,Y,h,m,s) #uart.write(dstr) print(dstr[0:-2]) pyb.delay(500) if data is not None: print("%4d %s" % (idx, str(data))) idx+=1
def led_blink(x): led = pyb.LED(x) led.on() time.sleep(5) led.off()