Skip to content

Instantly share code, notes, and snippets.

@VlastimilHovan
Created November 30, 2016 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save VlastimilHovan/fbdbb30b579cfd2442fd9fc7bc66e806 to your computer and use it in GitHub Desktop.
Save VlastimilHovan/fbdbb30b579cfd2442fd9fc7bc66e806 to your computer and use it in GitHub Desktop.
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):
if ((analog_val >= 835) & (analog_val <= 920)):
display.scroll("Black", delay=100)
if ((analog_val >= 700) & (analog_val <= 818)):
display.scroll("Blue", delay=100)
if ((analog_val >= 511) & (analog_val <= 613)):
display.scroll("Green", delay=100)
if ((analog_val >= 60) & (analog_val <= 170)):
display.scroll("White", delay=100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment