Ensure your device works with these simple tests.
examples/simpleio_tone_demo.py1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2# SPDX-License-Identifier: MIT 3 4""" 5'tone_demo.py'. 6 7================================================= 8a short piezo song using tone() 9""" 10 11import time 12 13import board 14 15import simpleio 16 17while True: 18 for f in (262, 294, 330, 349, 392, 440, 494, 523): 19 simpleio.tone(board.A0, f, 0.25) 20 time.sleep(1)examples/simpleio_shift_in_out_demo.py
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2# SPDX-License-Identifier: MIT 3 4""" 5'shift_in_out_demo.py'. 6 7================================================= 8shifts data into and out of a data pin 9""" 10 11import time 12 13import board 14import digitalio 15 16import simpleio 17 18# set up clock, data, and latch pins 19clk = digitalio.DigitalInOut(board.D12) 20data = digitalio.DigitalInOut(board.D11) 21latch = digitalio.DigitalInOut(board.D10) 22clk.direction = digitalio.Direction.OUTPUT 23latch.direction = digitalio.Direction.OUTPUT 24 25while True: 26 data_to_send = 256 27 # shifting 256 bits out of data pin 28 latch.value = False 29 data.direction = digitalio.Direction.OUTPUT 30 print("shifting out...") 31 simpleio.shift_out(data, clk, data_to_send, msb_first=False) 32 latch.value = True 33 time.sleep(3) 34 35 # shifting 256 bits into the data pin 36 latch.value = False 37 data.direction = digitalio.Direction.INPUT 38 print("shifting in...") 39 simpleio.shift_in(data, clk) 40 time.sleep(3)examples/simpleio_map_range_simpletest.py
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2# SPDX-License-Identifier: MIT 3 4""" 5'map_range_demo.py'. 6 7================================================= 8maps a number from one range to another 9""" 10 11import time 12 13import simpleio 14 15while True: 16 sensor_value = 150 17 18 # Map the sensor's range from 0<=sensor_value<=255 to 0<=sensor_value<=1023 19 print("original sensor value: ", sensor_value) 20 mapped_value = simpleio.map_range(sensor_value, 0, 255, 0, 1023) 21 print("mapped sensor value: ", mapped_value) 22 time.sleep(2) 23 24 # Map the new sensor value back to the old range 25 sensor_value = simpleio.map_range(mapped_value, 0, 1023, 0, 255) 26 print("original value returned: ", sensor_value) 27 time.sleep(2)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4