Instructions: SLIDER FOR MICRO:BIT V1A
TABLE OF CONTENTS Introduction................................................................................................................2 Parts ..........................................................................................................................3 Getting Started...........................................................................................................4 The Variable Resistor..........................................................................................
PARTS Please note that a BBC micro:bit is NOT included in this kit.
GETTING STARTED About Alligator Clips When using the alligator clips to connect your micro:bit to the MonkMakes Slider for micro:bit board, you have to be a bit careful how you connect the clips at the micro:bit end. The best way is to connect the clips vertically as shown below.
Connect the micro:bit to the Slider for micro:bit Use three of the alligator clip leads to connect your micro:bit and Slider for micro:bit together. Its a good idea to use the red lead for 3V, black for GND and a different color to connect the output of the Slider for micro:bit to your BBC micro:bit. You can use P0, P1 or P2 of your micro:bit, but for the example programs here, it is assumed that you have connected it to P2 as shown above.
THE VARIABLE RESISTOR The main component of the Slider for micro:bit is a sliding variable resistor (also often called a potentiometer or just pot). The other components on the board are designed to protect your micro:bit against accidental damage should you connect things the wrong way around and the amber power LED that show that the Slider for micro:bit is powered. Here's the schematic diagram of a variable resistor and micro:bit working together.
the reading will be 1023. Note that in practice the maximum value will be around 1013 rather than 1024 because of extra circuitry built into the Slider for micro:bit that protects the micro:bit. This example will display the reading when button A is pressed. Load it onto your micro:bit (see the link) and try moving the slider to various positions and then press button A and see what the reading is. Click on this link and then Download the program onto your micro:bit: https://makecode.microbit.
PROGRAM 1. SLIDER NUMBER This program displays a single digit between 0 and 9 depending on the position of the slider. To try it out using Blockcode, visit this webpage in your browser. https://makecode.microbit.org/_C9mFbkMwu7iw Click on the Download link at the bottom of the window and copy the HEX file onto your micro:bit. Once flashing is complete, you should see that the micro:bit's display shows a number.
PROGRAM 2. SLIDER BAR GRAPH This example uses the Blockcode plot bar graph of block to display a bar graph that responds to the slider position. Here's a link for the code: https://makecode.microbit.org/_HYtds3Yg9J32 Notice how the range of the plot bar graph of block is set to 0 to 1023. Move the slider about to change the display.
PROGRAM 3. SNAKE This example uses the Slider to make a wiggly snake animation when you move the slider. This is a little difficult to describe, so perhaps just try it out: https://makecode.microbit.org/_hgvDyoM2KVEP The code uses an array to keep track of the dot position on each row. The forever block first shuffles all the dot positions up one place using a for loop. It then clears the display and then sets the position of the bottom most dot to be determined by the slider position.
PROGRAM 4. MU PLOTTER This final program is only available for MicroPython using Mu because it uses Mu's Plotter facility to plot values sent out from the micro:bit to your computer over USB. Load the program onto your micro:bit (called mu_plotter.py) and then click on the Plotter button in the tool bar. Now when you move the slider about you will see the values change in the plot. Here's the code: from microbit import * import time while True: data = (pin2.read_analog(),) print(data) time.sleep(0.
MICROPYTHON WITH MU The code for this kit is available both as Block code and as MicroPython. If you would like to run the MicroPython versions of the programs rather than the Block code, then you can download all the programs from Github here: https://github.com/monkmakes/mb_slider Click on the green Code button and select the option Download ZIP. Extract the ZIP archive and you will find a directory containing the python programs for all the projects. You can then use the Mu editor (https://codewith.
TROUBLESHOOTING Problem: I am moving the slider, but the reading is not changing. Solution: Make sure that the analog read pin block has the same pin selected as is physically connected to the Slider for micro:bit's output. Problem: The amber power LED on the Slider for micro:bit is not lit. Solution: Make sure that your micro:bit itself is receiving power and that the GND and 3V connections of the micro:bit are connected to the GND and 3V connectors of the Slider.
LEARNING micro:bit Programming If you want to learn more about programming the micro:bit in MicroPython, then you should consider buying Simon Monk's book 'Programming micro:bit: Getting Started with MicroPython', which is available from all major book sellers. For some interesting project ideas, you might also like micro:bit for the Mad Scientist from NoStarch Press. You can find out more about books by Simon Monk (the designer of this kit) at: http://simonmonk.
MONKMAKES For more information on this kit, the product's home page is here: https://monkmakes.com/mb_slider As well as this kit, MonkMakes makes all sorts of kits and gadgets to help with your maker projects. Find out more, as well as where to buy here: https://monkmakes.com you can also follow MonkMakes on Twitter @monkmakes. From left to right: Electronics Starter Kit for micro:bit, Power for micro:bit (AC adapter not included) and 7 Segment for micro:bit.