{"product_id":"7-segment-for-micro-bit","title":"7-segment for micro:bit","description":"\u003cp\u003eThe 7-segment for micro:bit is a four digit 7-segment display for micro:bit. You can use it to display numbers, but it can also display letters and other characters!\u003c\/p\u003e\n\u003ch2\u003eFeatures\u003c\/h2\u003e\n\u003cul\u003e\n\u003cli\u003eEasy to connect (just needs one micro:bit pin plus power)\u003c\/li\u003e\n\u003cli\u003ePowered directly from micro:bit pins\u003c\/li\u003e\n\u003cli\u003eSend messages to the display using the micro:bit’s Serial blocks\u003c\/li\u003e\n\u003cli\u003eUseful for displaying readings from sensors, making clocks etc\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\u003e\u003cstrong\u003eConnecting to your micro:bit\u003c\/strong\u003e\u003c\/p\u003e\n\u003cp style=\"text-align: left;\"\u003e\u003cimg alt=\"\" src=\"\/\/cdn.shopify.com\/s\/files\/1\/0174\/1800\/files\/connecting_large.png?v=1536680881\" style=\"float: none;\"\u003e\u003c\/p\u003e\n\u003cp\u003eConnect the power pins GND and 3V between the micro:bit and the 7-Segment for micro:bit. Connect the Rx (receive) pin of the 7-Segment for micro:bit to any of the micro:bit’s pins.\u003c\/p\u003e\n\u003ch2\u003eBlock Code Examples\u003c\/h2\u003e\n\u003cp\u003e\u003cstrong\u003eDisplay ‘1234’\u003c\/strong\u003e\u003c\/p\u003e\n\u003cp\u003eThis first example displays the number 1234.\u003c\/p\u003e\n\u003cp\u003e\u003ca href=\"https:\/\/makecode.microbit.org\/_LiDE26cj4XMt\" target=\"_blank\"\u003e\u003cimg src=\"\/\/cdn.shopify.com\/s\/files\/1\/0174\/1800\/files\/basic_1234-300x232_large.png?v=1536680952\" alt=\"\"\u003e\u003c\/a\u003e\u003c\/p\u003e\n\u003cp\u003eThe \u003cstrong\u003eserial redirect to\u003c\/strong\u003e block allows the micro:bit to send (TX) serial messages on pin 0. It sets the RX pin to pin 16, but this is not used. When using the 7-segment display, the micro:bit only transmits messages, it does not receive them.\u003c\/p\u003e\n\u003cp\u003eNote that you need to set \u003cstrong\u003eat baud rate\u003c\/strong\u003e to 9600 as this is the speed of communication that the display is expecting.\u003c\/p\u003e\n\u003cp\u003eThe \u003cstrong\u003epause\u003c\/strong\u003e is necessary after redirecting serial communication to allow time for communication to start.\u003c\/p\u003e\n\u003cp\u003eUsing the \u003cstrong\u003eserial write number\u003c\/strong\u003e block writes a value to the display.\u003c\/p\u003e\n\u003cp\u003e\u003cstrong\u003eDISPLAY ‘Byte’\u003c\/strong\u003e\u003c\/p\u003e\n\u003cp\u003eAs well as displaying numbers, you can also display text, although with just seven segments per digit many of the letters and punctuation are very approximate. For example we could display the word ‘Byte’ using the code below.\u003c\/p\u003e\n\u003cp\u003e\u003ca href=\"https:\/\/makecode.microbit.org\/_WJLPymRDyd3m\" target=\"_blank\"\u003e\u003cimg src=\"\/\/cdn.shopify.com\/s\/files\/1\/0174\/1800\/files\/basic_byte-300x203_large.png?v=1536681013\" alt=\"\"\u003e\u003c\/a\u003e\u003c\/p\u003e\n\u003cp\u003eNote that in this case, we are using the\u003cstrong\u003e serial write string\u003c\/strong\u003e block as we want to display text rather than a number.\u003c\/p\u003e\n\u003cp\u003e\u003cstrong\u003eClearing the Display\u003c\/strong\u003e\u003c\/p\u003e\n\u003cp\u003eIf you just send text or numbers to the display using \u003cstrong\u003eserial write string\u003c\/strong\u003e or \u003cstrong\u003eserial write number\u003c\/strong\u003e, then each time you send another character it pushes all the currently displayed characters one position to the left and then puts the new character in the right-most position. If you send the special character “\/”, the display will be cleared.\u003c\/p\u003e\n\u003cp\u003e\u003cstrong\u003eBuffered Mode\u003c\/strong\u003e\u003c\/p\u003e\n\u003cp\u003eIf you want your display to update repeatedly, then just writing new values as described above will result in the display flickering. To avoid this you need to use the display in buffered mode. In this mode, you compose what you want to be displayed and then when you are ready tell the display to change whatever is currently being displayed to what you now want to be displayed.\u003c\/p\u003e\n\u003cp\u003eThe special character “,” (comma) is used to switch the display into buffered mode and also to update the display. The next example uses the display in buffered mode.\u003c\/p\u003e\n\u003cp\u003e\u003cstrong\u003eCountdown Timer\u003c\/strong\u003e\u003c\/p\u003e\n\u003cp\u003eThis timer starts at a number (change n to the number up to 9999 that you want to count down from). When the countdown reaches 0 the message “Done” will be displayed.\u003c\/p\u003e\n\u003cp\u003e\u003ca href=\"https:\/\/makecode.microbit.org\/_hC0Max9tDec8\" target=\"_blank\"\u003e\u003cimg src=\"\/\/cdn.shopify.com\/s\/files\/1\/0174\/1800\/files\/countdown_better-1024x968_large.png?v=1536681073\" alt=\"\"\u003e\u003c\/a\u003e\u003c\/p\u003e\n\u003cp\u003eThe value of count actually increases from 0 to whatever \u003cstrong\u003en\u003c\/strong\u003e is, but the number displayed is\u003cstrong\u003e n – count\u003c\/strong\u003e, so the number displayed decreases.\u003c\/p\u003e\n\u003cp\u003eEach time around the loop four spaces are sent to the display to clear it of any existing number. This is an alternative to using “\/” but unlike “\/” does not change the display mode back to non-buffered. The number is then sent to the display followed by the “,” (comma) command to tell the display to swap its current contents for the new value.\u003c\/p\u003e\n\u003cp\u003eWhen the count down has finished, the message “done” is displayed. The “\/” at the start of this message puts the display back into non-buffered mode so that a final comma is not needed to refresh the display.\u003c\/p\u003e\n\u003cp\u003e \u003c\/p\u003e\n\u003cp\u003e\u003cstrong\u003eThermometer\u003c\/strong\u003e\u003c\/p\u003e\n\u003cp\u003eThis display is a great companion to the \u003ca href=\"https:\/\/www.monkmakes.com\/mb_sensor\/\"\u003eMonkMakes Sensor for micro:bit\u003c\/a\u003e. In this example, we use this display to show the current temperature.\u003c\/p\u003e\n\u003cp\u003e\u003cimg src=\"\/\/cdn.shopify.com\/s\/files\/1\/0174\/1800\/files\/thermometer-1024x812_large.png?v=1536681144\" alt=\"\"\u003e\u003c\/p\u003e\n\u003cp\u003eAs you can see, the micro:bit supplies power to the Sensor board that then supplies power to the display.\u003c\/p\u003e\n\u003cp\u003eHere is the code for the thermometer. Click on it to open it.\u003c\/p\u003e\n\u003cp\u003e\u003ca href=\"https:\/\/makecode.microbit.org\/_92EKHzDhJEeR\" target=\"_blank\"\u003e\u003cimg src=\"\/\/cdn.shopify.com\/s\/files\/1\/0174\/1800\/files\/thermometer-1-1024x762_large.png?v=1536681188\" alt=\"\"\u003e\u003c\/a\u003e\u003c\/p\u003e\n\u003cp\u003eFor more information on how the temperature measurement part of the code works, see \u003ca href=\"https:\/\/www.monkmakes.com\/mb_sensor\/\" target=\"_blank\"\u003ethe Sensor boards page\u003c\/a\u003e.\u003c\/p\u003e\n\u003cp\u003eTo display the temperature the display is used in “buffered mode”. The next value to display is first blanked and then the temperature sent to the display followed by “*C,”. The * character displays something close to the degrees symbol and the comma on the end tells the display that now is the time to switch what is displayed to the new message.\u003c\/p\u003e\n\u003ch2\u003eTrouble Shooting\u003c\/h2\u003e\n\u003cp\u003e\u003cstrong\u003eProblem\u003c\/strong\u003e: The display is not very bright.\u003c\/p\u003e\n\u003cp\u003e\u003cstrong\u003eSolution\u003c\/strong\u003e: The limited current available from the micro:bit means that the display has to be kept at a low brightness to be able to work. The display will be less bright when using batteries through the battery connector than when using a USB power supply.\u003c\/p\u003e\n\u003cp\u003e\u003cstrong\u003eProblem\u003c\/strong\u003e: The display is not refreshing.\u003c\/p\u003e\n\u003cp\u003e\u003cstrong\u003eSolution\u003c\/strong\u003e: The display takes time to operate and so if you try and refresh it too fast, it can hang. If it does this, introduce a longer delay between refreshes using the \u003cstrong\u003epause\u003c\/strong\u003e block. Momentarily un-clipping the positive power lead to the display will cause it to reset if the display has stopped updating.\u003c\/p\u003e","brand":"Monk Makes","offers":[{"title":"Default Title","offer_id":12933036179539,"sku":"MNK00066","price":14.95,"currency_code":"EUR","in_stock":false}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0174\/1800\/products\/7-seg_3_of_3.JPG?v=1536682571","url":"https:\/\/shop.pimoroni.com\/en-eu\/products\/7-segment-for-micro-bit","provider":"Pimoroni Ltd","version":"1.0","type":"link"}