Skip to content

Instantly share code, notes, and snippets.

x_pos = 0
x_pos_1 = 0
y_pos_1 = 0
remind = 0
remind_1 = 0
remind_2 = 0
move_counter = 0
player_ = 1
from microbit import *
pin8.set_analog_period(1)
pin12.set_analog_period(1)
pin0.set_analog_period(1)
pin16.set_analog_period(1)
def_speed = 512
def move_forward():
pin8.write_analog(def_speed)
pin12.write_analog(0)
from microbit import *
pin0.set_analog_period(10)
pin1.set_analog_period(10)
motor_direction = 0
zero_pos = 155
f_pos_1 = 165
f_pos_2 = 145
r_pos_1 = 0
r_pos_2 = 0
from microbit import *
analog_val = 0
analog_val_old = 0
while True:       
analog_val = pin0.read_analog()           
analog_val_old = analog_val   
analog_val = (analog_val * 0.0029297)   
from microbit import *
analog_val = 0
analog_val_old = 0
#display.scroll("Simple Voltmeter with autorange.", delay=100)
while True:
analog_val = pin0.read_analog()
if (analog_val != (analog_val_old + 1)|(analog_val_old - 1)):
from microbit import *
time_ = 1
time_1 = 1
axis_x = 0
pin16.write_digital(1)
pin15.write_digital(1)
pin14.write_digital(1)
pin13.write_digital(1)
@VlastimilHovan
VlastimilHovan / stopwatch.py
Created February 1, 2017 12:04
BBC microbit stopwatch
from microbit import *
def clear_line(line):
display.set_pixel(0, line, 0)
display.set_pixel(1, line, 0)
display.set_pixel(2, line, 0)
display.set_pixel(3, line, 0)
display.set_pixel(4, line, 0)
@VlastimilHovan
VlastimilHovan / measuring tape.py
Created December 1, 2016 20:06
BBC microbit digital measuring tape (code release)
# with this code you need to make hardware changes to sensor
# or you can add on code to disable pull resistor on pin16
from microbit import *
remind = 0
remind_1 = 0
counter = 0
display.scroll("Hello Girls")
@VlastimilHovan
VlastimilHovan / maths game.py
Created December 1, 2016 19:57
BBC microbit maths game (code release)
#Written by Vlastimil Hovan 2016
#Please include text above in any redistribution
#Thanks
from microbit import *
import random
remind = -1
operation_ = 0
number_1 = 0
@VlastimilHovan
VlastimilHovan / colour sensor.py
Created November 30, 2016 20:10
BBC microbit colour sensor (code release)
from microbit import *
analog_val = 0
while True:
analog_val = pin0.read_analog()
if (button_a.is_pressed() == True):