Create a sketch using the
"0.96 OLED screen show string" block that simply says "Hello." You can find this block in the I2C menu. Or type OLED into the block search menu.
Upload it. Is it working?
Next, build this sketch ➡
(To enlarge, right click, open image in new tab)
Or, download OLED_pot_select.cdc, save to your computer, and open in Codecraft using
Files ... Open local projects
Learning objectives:
Using the OLED to display text and graphics
Using the Serial monitor for debugging
Map function
Nested If blocks
Click on "</>" to review the Arduino code sketch generated by Codecraft.
The OLED module uses the I2C communication protocol.
References:
Change the OLED images and text.
Add more selection choices
Dim the LED using the potentiometer and display the dimming value on the OLED display using a bargraph. (Create different images for each brightness level)
If you want to display the value of a variable using the "OLED screen show string" block, you'll need to convert the variable to a string using the "to String" block.
Otherwise, your sketch will not compile and you'll see the cryptic "Upload Failed" message. (Codecraft bug...)
You can find the "to String" block in the "Operator" menu, near the bottom.
This will not compile:
Need to include the "ToString" operator:
You can do a lot more with the OLED display using the Arduino IDE, such as changing the fonts and font sizes, drawing graphic (lines, circles), and flipping the display.
Complete: Displaying Data on OLED
Learn about what you can do with your OLED display.
See the u8g2 reference
Use a different font. Or draw a line, circle, or rectangle.
Look at the examples in:
File ... Examples ... Examples from Custom Libraries ... u8g2 ... FullBuffer ... GraphicsTest
You need to specify the OLED display you are using. Remove the comment from line 65:
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
your ideas?