3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Experiment 0: Hello, micro:bit! Introduction “Hello World” is the term we use to define that first program you write in a programming language or on a new piece of hardware. Essentially it is a simple piece of code that gives you a quick win (fingers crossed) and a first step in learning. It also gives you a chance to make sure everything is up and running and A-OK.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com keyed to fit inside of the forever block, and if you have the volume up on your computer you will hear a satisfying ‘click’ noise when you let go of the block. The show leds block has an array of squares that symbolize the LED array. If you click on a square, it will turn red, which means that it is on.
/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com To turn this static image into an animation, we need another show leds block to place just under the first block. You can then make a second drawing with this set of rectangles. In your simulator you will see the images switching really, really fast. We need to slow this down! To slow your animation down, you will use the pause block, which is under the basic block set.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com The reason we are using two and placing one at the end is that this program is a loop. Without the block at the end, the image in your animation will change really, really fast. We have built up an example in the next section where you can download the file and try it out on your own micro:bit, or use the simulator.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com That’s it! Your micro:bit will flash for a few seconds, and then your program will start automatically. Yes! Win! Note: You may need to disable your ad/pop-up blocker to see the simulated circuit! Experiment 1: Blinking an LED Introduction LEDs are small, powerful lights that are used in many different applications.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com This breakout board makes it much easier to use all of the pins available on the micro:bit edge connector in a more user-friendly way. We also broke out ground and VCC (3.3 volts) for your convenience. https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com The breakout board lines up with the pins of a breadboard. We recommend using a full-sized breadboard with this breakout to give you enough room to prototype circuits on either end of the breadboard. Also, for durability’s sake, insert the breakout pins about halfway into the breadboard so there is support under the board for when you insert a micro:bit and/or pull it out.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Components like resistors need to have their legs bent into 90° angles in order to correctly fit the breadboard sockets. You can also cut the legs shorter to make them easier to work with on the breadboard. Wiring Diagram for the Experiment https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Having a hard time seeing the circuit? Click on the wiring diagram for a closer look. Running Your Script Either copy and paste, or re-create the following code into your own MakeCode editor by clicking the open icon in the upper righthand corner of the editor. You can also just download this example by clicking the download button in the lower right-hand corner of the code window. https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming environment and simulated circuit! Code to Note Let’s take a look at the code blocks in this experiment. If you are having a hard time viewing this code, click on the image above to get a better look! Forever The forever block is a block that loops any other command blocks inserted into it over and over again…forever.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Troubleshooting LED Not Blinking Make sure you have it wired correctly and the correct pin to ground. Remember, short pin to ground; long pin to signal. Still No Success A broken circuit is no fun. Send us an email, and we will get back to you as soon as we can: techsupport@sparkfun.com . Experiment 2: Reading a Potentiometer Introduction In this circuit you will work with a potentiometer.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com A potentiometer is a resistance-based analog sensor that changes its internal resistance based on the rotation of its knob. The potentiometer has an internal voltage divider enabling you to read the change in voltage on the center pin with a microcontroller (i.e. micro:bit). https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com To hook up the potentiometer, attach the two outside pins to a supply voltage (3.3V in this circuit) and ground. It doesn’t matter which is connected where, as long as one is connected to power, and the other to ground. The center pin is then connected to an analog input pin so the micro:bit can measure the change in voltage.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Having a hard time seeing the circuit? Click on the wiring diagram for a closer look. Note: The full sized breadboard power rails have a break down the middle. If you end up using the lower half of the power rail you will need to jump between the upper end and lower end.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming environment and simulated circuit! Code to Note Let’s take a look at the code blocks in this experiment. If you are having a hard time viewing this code, click on the image above to get a better look! A “variable” is a placeholder for values that may change in your code.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Troubleshooting Sporadically Working This is most likely due to a slightly dodgy connection with the potentiometer’s pins. This can usually be conquered by holding the potentiometer down or moving the potentiometer circuit somewhere else on your breadboard.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com The photoresistor changes its resistance based on the light to which it is exposed. https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com To use this with the micro:bit, you will need to build a voltage divider with a 10kΩ resistor, as shown in the wiring diagram for this experiment. The micro:bit cannot read a change in resistance, only a change in voltage. A voltage divider allows you to translate a change in resistance to a corresponding voltage value.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Having a hard time seeing the circuit? Click on the wiring diagram for a closer look. Note: The full sized breadboard power rails have a break down the middle. If you end up using the lower half of the power rail you will need to jump between the upper end and lower end.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming environment and simulated circuit! Code to Note Let’s take a look at the code blocks in this experiment. If you are having a hard time viewing this code, click on the image above to get a better look! On Start In previous experiments you have only used the forever block, which loops your code forever.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Troubleshooting LED Remains Dark You may have been leaning over the light sensor when the code started. Make sure the light sensor is reading the normal light in the room at startup. Try resetting the micro:bit. Still Not Quite Working Double-check your wiring of the signal pin; sometimes you miss a breadboard connection by a row.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com by turning different colors on and off to combine them. For example, if you turn on the red pin and green pin, the RGB will light up as yellow. But which pin is which color? Pick up the RGB so that the longest pin (common ground) is aligned to the left as shown in the graphic below. The pins are Red, Ground, Green and Blue — starting from the far left. https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: When wiring the RGB, each colored pin still needs a current-limiting resistor in line with the micro:bit’s I/O pin that you plan to use to control it, as with any standard LED. Hardware Hookup Ready to start hooking everything up? Check out the wiring diagram and hookup table below to see how everything is connected.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Having a hard time seeing the circuit? Click on the wiring diagram for a closer look. Run Your Script Either copy and paste, or re-create the following code into your own MakeCode editor by clicking the open icon in the upper righthand corner of the editor. You can also just download this example by clicking the download button in the lower right-hand corner of the code window. https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming environment and simulated circuit! Code to Note Let’s take a look at the code blocks in this experiment. If you are having a hard time viewing this code, click on the image above to get a better look! On Button Press You will find the on Button Press block under the input block section.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Troubleshooting LED Remains Dark or Shows Incorrect Color With the four pins of the LED so close together, it’s sometimes easy to misplace one. Double check that each pin is where it should be. Seeing Red The red diode within the RGB LED may be a bit brighter than the other two. To make your colors more balanced, use a higher ohm resistor.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Analog vs. Digital Digital Logic Introducing the Single-Pole, Double-Throw (SPDT) Switch The Single-Pole, Double-Throw (SPDT) switch has a common pin in the middle and then two other pins. A connection will be made between the middle pin and one of the other pins depending on the position of the switch. https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Reading a switch is similar to a button. You need to connect the common pin to a digital General Purpose Input/Output (GPIO) pin to the micro:bit board from a breadboard. The other pins can be connected to 3.3V and ground. It doesn’t matter which pin is which. When you move the switch, the common pin will either be HIGH (connected to 3.3V) or LOW (connected to ground).
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Having a hard time seeing the circuit? Click on the wiring diagram for a closer look. Note: The full sized breadboard power rails have a break down the middle. If you end up using the lower half of the power rail you will need to jump between the upper end and lower end.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming environment and simulated circuit! Code to Note Let’s take a look at the code blocks in this experiment.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Troubleshooting Light Not Turning On The wires for the switch are right next to each other. Make sure that signal is in the center with voltage and ground on the outside pins. If you connect ground and voltage, your board will short out and shut down. Make sure your power LED is on. If it is off, pull the signal wire and see if that changes anything.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com somewhat familiar with the concepts in these tutorials: Switch Basics Analog vs. Digital Introducing the Push Button A momentary push button closes or completes the circuit only while it is being pressed. The button has four pins, which are broken out into two sets of two pins. When you press down on the button and get a nice “click,” the button bridges the two sets of pins and allows current to flow through the circuit.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com How do you know which pins are paired up? The buttons included in this kit will only fit across the breadboard ditch in one direction. Once you get the button pressed firmly into the breadboard (across the ditch), the pins are horizontally paired. The pins toward the top of the breadboard are connected, and the pins toward the button of the breadboard are connected. Note: Not all buttons share this pin format.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Having a hard time seeing the circuit? Click on the wiring diagram for a closer look. Note: The full sized breadboard power rails have a break down the middle. If you end up using the lower half of the power rail you will need to jump between the upper end and lower end.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming environment and simulated circuit! Code to Note Let’s take a look at the code blocks in this experiment. If you are having a hard time viewing this code, click on the image above to get a better look! Set Pull Pin When you start your micro:bit, some pins can be set to be naturally on or naturally off.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Finally, inside of the forever block is a more complex if block, which is an if / if else / else tree. To build this more complex “if” statement, add a standard if / else block into your program. Then click on this small gear in the upper left-hand corner of the block. This will open a tiny interface with more blocks in it. You can drag more else if blocks into the structure here to build your decision tree.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Light Not Turning On The push button is square, and because of this it is easy to put it in the wrong way. Give it a 90-degree twist and see if it starts working. Underwhelmed No worries; these circuits are all super stripped-down to make playing with the components easy, but once you throw them together the sky is the limit.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com If you are looking at the flat face with text on it, the center pin is your signal pin, the left-hand pin is supply voltage (3.3V in this tutorial), and the right-hand pin connects to ground. Pro Tip: The TMP36 looks a lot like a transistor. Put a dot of fingernail polish on the top of your TMP36 so it’s easy to find.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Having a hard time seeing the circuit? Click on the wiring diagram for a closer look. Run Your Script Either copy and paste, or re-create the following code into your own MakeCode editor by clicking the open icon in the upper righthand corner of the editor window. You can also just download this example by clicking the download button in the lower right-hand corner of the code window. https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming environment and simulated circuit! Code to Note Let’s take a look at the code blocks in this experiment.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Once you select the TMP36 package there should be a TMP36 code block drawer to select from in your blocks menu. This drawer has only one block in it and that is a block that returns the temperature from a TMP36 sensor connected to a specific pin in fahrenheit or celcius. Show Number The Show Number block accepts a number value and then displays it on the LED array. That’s it! Pretty simple.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Troubleshooting Temperature Value is Unchanging Try pinching the sensor with your fingers to heat it up or pressing a bag of ice against it to cool it down. Temperature Sensor is Really Hot! You have wired it backward! Unplug your micro:bit immediately, let the sensor cool down, and double-check your wiring. If you catch it soon enough, your sensor may not have been damaged and may still work.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Unlike the action of most motors that continuously rotate, a servo motor can rotate to and hold a specific angle until it is told to rotate to a different angle. You can control the angle of the servo by sending it a PWM (Pulse Width Modulation) pulse train; the PWM signal is mapped to a specific angle from 0 to 180 degrees. Inside of the servo there is a gearbox connected to a motor that drives the shaft.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Hardware Hookup Ready to start hooking everything up? Check out the wiring diagram below to see how everything is connected. Polarized Components Pay special attention to the component’s markings indicating how to place it on the breadboard. Polarized components can only be connected to a circuit in one direction. Connect 3x jumper wires to the female 3-pin header on the servo.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming environment and simulated circuit! Code to Note Let’s take a look at the code blocks in this experiment. If you are having a hard time viewing this code, click on the image above to get a better look! Set “Direction To” In the On Start block we set the direction variable to 1 .
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Troubleshooting Servo Not Twisting Even with colored wires, it is still shockingly easy to plug a servo in backward. This might be the case. Still Not Working A mistake we made a time or two was simply forgetting to connect the power (red and black wires) to 3.3 volts and ground (GND).
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com If you turn the voltage on and off fast enough, you get different beeps, squeals, chirps and buzzes. You will use PWM to control the speed of turning the piezo on and off — and, in turn, the audio frequency coming out of the buzzer. Adjusting the PWM enables you to get legitimate notes out of the buzzer. If you flip the buzzer over and look at the bottom, you will see that one pin has a (+) next to it.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Hardware Hookup Ready to start hooking everything up? Check out the wiring diagram below to see how everything is connected. Polarized Components Pay special attention to the component’s markings indicating how to place it on the breadboard. Polarized components can only be connected to a circuit in one direction. Wiring Diagram for the Experiment https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Having a hard time seeing the circuit? Click on the wiring diagram for a closer look. Note: The full sized breadboard power rails have a break down the middle. If you end up using the lower half of the power rail you will need to jump between the upper end and lower end.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming environment and simulated circuit! Code to Note Let’s take a look at the code blocks in this experiment.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com While the image shows black momentary pushbuttons, you can use any colored button as long as it is momentary pushbutton to trigger the sounds! Troubleshooting No Sound Given the size and shape of the piezo buzzer, it is easy to miss the right holes on the breadboard. Try double-checking its placement. Also, double check to make sure the push button is wired correctly.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com parts. Why? Because it is on the micro:bit itself! On the back of the micro:bit you can see a number of small chips. One of them is the accelerometer. https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com An accelerometer is a sensor that measures the gravitational forces pulling on it in all three dimensions of the chip’s X, Y and Z axes. Not only can an accelerometer measure the raw forces pulling on the chip and the object that the chip is sitting on, but it can also detect steps, shakes and other motions that have a specific pattern.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Hardware Hookup Ready to start hooking everything up? Check out the wiring diagram below to see how everything is connected. Polarized Components Pay special attention to the component’s markings indicating how to place it on the breadboard. Polarized components can only be connected to a circuit in one direction.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming environment and simulated circuit! Code to Note Let’s take a look at the code blocks in this experiment. If you are having a hard time viewing this code, click on the image above to get a better look! Acceleration The acceleration block can be found under the input blocks group.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com What You Should See At the beginning of the program the servo should move to 90 degrees and then react to the orientation of the micro:bit. If you hold the micro:bit flat, the servo will be at 90 degrees. Then if you tilt the servo to the left, it will move less than 90 degrees toward the value of 15. If you move it to the right, the servo will move toward 165.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Pulse Width Modulation Introducing the Compass (Magnetometer) In the previous experiment you learned about the accelerometer, which measured gravity. The compass, or technically the magnetometer, measures a magnetic field. Magnetic fields come in different sizes, but the biggest is the one produced by Earth itself, which is why compasses work. https://learn.sparkfun.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com The magnetometer detects magnetic north and then represents your heading in degrees with north being 0 degrees, east being 90 degrees, south being 180 degrees and west being 270. Pretty cool! Now let’s put this compass to good use! Hardware Hookup Ready to start hooking everything up? Check out the wiring diagram below to see how everything is connected.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Having a hard time seeing the circuit? Click on the wiring diagram for a closer look. Note: The full sized breadboard power rails have a break down the middle. If you end up using the lower half of the power rail you will need to jump between the upper end and lower end.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming environment and simulated circuit! Code to Note Let’s take a look at the code blocks in this experiment.
3/7/2018 SparkFun Inventor's Kit for micro:bit Experiment Guide - learn.sparkfun.com Note: If you calibrate your micro:bit while inside and in a proximity to your computer or something that produces a larger magnetic field it will skew your micro:bits sense of direction.