I bought a 0.96”, 128x64, OLED for $7 (price range ~$4-10 based on quantity). It is tiny, the display being about 2.5 cm x 1.25 cm. It is an I2C device that needs 3.3-5V. You connect it to the micro:bit via pins 19 (SCL) & 20 (SDA). Some of the extension boards have grove port connectors (white 4 pin jacks) already set up for this to make it easier to connect (1 cable with 4 wires). There are a couple of options for makecode extensions with different number of blocks. The third seems to be an older version of the first (both by Tinkeracademy). The second, by Author: shaoziyang, gives you more control over what and where {though it does not have a block for drawing diagonal lines}. The first block that has to be used is an “initialize” or “init” block. The default address for the device is 60. I tend to put that in “on start” , but it just has to come before using the other blocks in a “forever” block if you prefer. The next thing that is good to know is that there is a zoom mode which enlarges things to make it easier to read, but also shifts it to 64x32 pixel resolution (zoom=true in the code ; tinkeracademy block set default to this). This means that with zoom=true you have 4 lines of text vs 8, and 12 vs 24 columns of text. You need to know this because you can choose where to start the text. Likewise, if drawing lines or pixels, you have 64 vs 128 for x position and 32 vs 64 for y position in zoom=true mode. Third thing is color. Some of the blocks have a color part and your choices are 0 or 1. Color 1 is “normal”, black screen and yellow or blue (for my device, the first line is yellow text, other 3 are blue in zoom=true mode). Color 0 is inverted, text is black and highlighted in the line color. The obvious use for this is to display sensor or variable data. This can be done easily with the makecode blocks (code). ![]() . Here is my setup. The oled is connected to a BitBooster from lectrify in order to access pins 19 & 20. I believe graphing can be done, but you would have to utilize micropython. The same is true for displaying icons/bitmaps. More exploration is needed for this. (possible micropython instructions https://www.littlebird.com.au/a/how-to/81/0-96-oled-screen-with-micro-bit and http://www.suppertime.co.uk/blogmywiki/2019/11/microbit-oled-display/ update You can plot pixels using the blocks in makecode, so you can graph. The hard part is scaling the y values you get to the screen. Create a variable for the x coordinate of the pixel and set it to 0. If we have zoom=true, then we have 64 possible x values, so the repeat loop can repeat 64 times (collect 64 data points)(maybe it can only repeat 63 times???). That also means that we have 32 possible values for y. So you have to scale your input to fit between 0 & 31. With a twist. 0 is up top, 31 is at the bottom. I am doing temperature in Celsius, so I did a simple "31 - rounding of temperature". I rounded because I am not sure if the sensor rounds or does integers and pixels have integer coordinates. If the temp is 22 C, it will color in a pixel at y=9 (towards the top); if the temp is 0 it will color at y=31 (the bottom). My code cannot register temps below 0. Then I change X by one to collect the next data point. I did that every half second. The "clear" command is to erase the last line graphed when i want to graph again. Remember, if you use "zoom=false", you will have 128 x values and 64 y values for coordinates. So repeat goes to 127 (or 128???) and data values need to scale from 0-64, upside down.
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
Archives
December 2022
Categories |