Skip to content

Instantly share code, notes, and snippets.

@fizban99
fizban99 / hcsr04.py
Created March 16, 2017 21:45
micro:bit micropython library for the HC-SR04 ultrasonic sensor
from microbit import spi
from microbit import pin13, pin14, pin15
class HCSR04:
def __init__(self, tpin=pin15, epin=pin14, spin=pin13):
self.trigger_pin = tpin
self.echo_pin = epin
self.sclk_pin = spin
@fizban99
fizban99 / us100.py
Created March 16, 2017 21:43
micro:bit library to read from an ultrasonic sensor Us-100
from microbit import uart, pin14, pin15, sleep
from sys import print_exception
class US100:
def __init__(self, tpin=pin15, rpin=pin14):
self.tx_pin = tpin
self.rx_pin = rpin