{"product_id":"relay-for-micro-bit","title":"Relay for micro:bit","description":"\u003cp\u003eThe MonkMakes Relay for micro:bit is a solid-state (no moving parts) relay that allows an output of a micro:bit to turn things on and off.\u003c\/p\u003e\n\u003cp\u003eA micro:bit can turn an LED on and off directly, but anything more powerful requires something like a relay or a transistor. Using a transistor to switch something on and off requires a shared ground connection with the micro:bit and a knowledge electronics that you or your students may not be ready for. The MonkMakes Relay for micro:bit is much easier to use, acting like a simple micro:bit controlled switch.\u003c\/p\u003e\n\u003cp\u003eThis relay can be used to switch low voltage devices such as light bulbs, a motor, a small heating element or even a string of 12V LED lighting. The voltage needs to be kept under 16V, but the relay will automatically protect itself against too much current.\u003c\/p\u003e\n\u003cp\u003e\u003cimg src=\"\/\/cdn.shopify.com\/s\/files\/1\/0174\/1800\/files\/connected-copy-1024x656_large.jpg?v=1512399592\" alt=\"\"\u003e\u003c\/p\u003e\n\u003ch2\u003eFEATURES\u003c\/h2\u003e\n\u003cul\u003e\n\u003cli\u003eSolid-sate relay (up to 2 Amps)\u003c\/li\u003e\n\u003cli\u003eActive LED indicator\u003c\/li\u003e\n\u003cli\u003eResettable ‘polyfuse’ to protect against over-current\u003c\/li\u003e\n\u003cli\u003eCompatible with micro:bit v1 and v2!\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003ch2\u003eGetting Started\u003c\/h2\u003e\n\u003cp\u003eConnecting your micro:bit\u003c\/p\u003e\n\u003cp\u003eThe Relay requires just two connections to the micro:bit. One to GND (ground) and one to whatever pin is to be used to control the relay’s switching action.\u003c\/p\u003e\n\u003cp\u003eWhen attaching the alligator clips to the micro:bit, make sure that the clips are perpendicular to the board so that they are not touching any of the neighbouring connectors on the micro:Bit edge connector.\u003c\/p\u003e\n\u003cp\u003eHere’s an example of how you could wire up a MonkMakes Relay for micro:bit to turn an old fashioned light bulb on and off.\u003c\/p\u003e\n\u003cp\u003e\u003cimg src=\"\/\/cdn.shopify.com\/s\/files\/1\/0174\/1800\/files\/wiring_relay-929x1024_large.png?v=1512399623\" alt=\"\"\u003e\u003c\/p\u003e\n\u003cp\u003e\u003cstrong\u003eHEX File\u003c\/strong\u003e\u003c\/p\u003e\n\u003cp\u003eThe quickest way to try out your relay is to \u003ca href=\"https:\/\/monkmakes.com\/blink_relay.hex\" target=\"_blank\"\u003eDOWNLOAD THIS HEX FILE \u0026gt;\u003c\/a\u003eand then copy it onto your micro:bit. The program will turn the relay on and off once a second.\u003c\/p\u003e\n\u003cp\u003e\u003cstrong\u003eJavaScript Blocks Editor\u003c\/strong\u003e\u003c\/p\u003e\n\u003cp\u003eSet the controlling pin to 1 and the relay contacts will close, set it to 0 and the contacts will open again. Its as simple as that. So, to make your relay turn on and off once a second, \u003ca href=\"http:\/\/python.microbit.org\/editor.html\" target=\"_blank\"\u003eopen the Blocks Editor\u003c\/a\u003e, add a \u003cem\u003eforever\u003c\/em\u003e block and then the \u003cem\u003edigital write\u003c\/em\u003e blocks from the \u003cem\u003epins\u003c\/em\u003e category and the \u003cem\u003epauses\u003c\/em\u003e from the \u003cem\u003ebasic \u003c\/em\u003ecategory.\u003c\/p\u003e\n\u003cp\u003eYou can also click on the image of the blocks below to open up the Blocks Editor on this project.\u003c\/p\u003e\n\u003cp\u003e\u003ca href=\"https:\/\/makecode.microbit.org\/_R9Aa5gejw1p2\" target=\"_blank\"\u003e\u003cimg src=\"\/\/cdn.shopify.com\/s\/files\/1\/0174\/1800\/files\/blocks_large.png?v=1512399662\" alt=\"\"\u003e\u003c\/a\u003e\u003c\/p\u003e\n\u003cp\u003e\u003cstrong\u003eMicroPython\u003c\/strong\u003e\u003c\/p\u003e\n\u003cp\u003ePaste the following code into the \u003ca href=\"http:\/\/python.microbit.org\/editor.html\" target=\"_blank\"\u003ePython window\u003c\/a\u003e and then Download the file and copy it onto your your micro:bit.\u003c\/p\u003e\n\u003cp\u003e\u003ccode\u003efrom microbit import *\u003cbr\u003e\u003cbr\u003ewhile True:\u003cbr\u003e    pin0.write_digital(True)\u003cbr\u003e    sleep(500)\u003cbr\u003e    pin0.write_digital(False)\u003cbr\u003e    sleep(500)\u003c\/code\u003e\u003c\/p\u003e\n\u003ch2\u003eAnalog Outputs\u003c\/h2\u003e\n\u003cp\u003eThe latest MonkMakes Relay for micro:bit can do more than just switch things on and off. It can also be used with micro:bit analog outputs. Look closely at your Relay for micro:bit and is it has the version number \u003cstrong\u003ev1ev\u003c\/strong\u003e (under the word ‘Board’) then it can be used with the ‘analog write’ block in the blocks editor or the ‘write_analog’ function in MicroPython. If your board has the version number \u003cstrong\u003ev1e\u003c\/strong\u003e then it is not suitable for use with analog outputs – sorry you were unlucky to get one of the small batch of first boards to be sold.\u003c\/p\u003e\n\u003cp\u003eThe output of the Relay for micro:bit is not linear at low PWM and high PWM values as the following chart illustrates.\u003c\/p\u003e\n\u003cp\u003e\u003cimg src=\"\/\/cdn.shopify.com\/s\/files\/1\/0174\/1800\/files\/graph_large.png?v=1512399750\" alt=\"\"\u003e\u003c\/p\u003e\n\u003cp\u003eThe y-axis shows the current in mA for a test load resistor supplied from a constant voltage source. The x-axis is the analog write value (0 to 1023). As you can see, there is a dead zone up to a analog output value of about 100, followed by a relatively good linear region right up to about 1000, after which the output effectively becomes ‘on’.\u003c\/p\u003e\n\u003cp\u003eThe tests were carried out at the default PWM frequency of 50Hz for the micro:bit. Lower frequency PWM is expected to produce more linear results.\u003c\/p\u003e","brand":"Monk Makes","offers":[{"title":"Default Title","offer_id":1447864369162,"sku":"MNK00061","price":8.95,"currency_code":"EUR","in_stock":false}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0174\/1800\/products\/Monk_1_of_3.JPG?v=1539263534","url":"https:\/\/shop.pimoroni.com\/en-eu\/products\/relay-for-micro-bit","provider":"Pimoroni Ltd","version":"1.0","type":"link"}