Working with OLED

header-lesson-06

Working with OLED#

Click on the “OLED” drawer in the Toolbox.

makecode-elecfreaks-oled-01

Select the initialize OLED block.

makecode-elecfreaks-oled-02

Place the initialize OLED block in the on start block. This only needs to run once. Do not change the dimensions.

makecode-elecfreaks-oled-03

The forever block can be moved.

makecode-elecfreaks-oled-04

It is now unobstructed.

makecode-elecfreaks-oled-05

Click on the “OLED” drawer of the Toolbox.

makecode-elecfreaks-oled-06

Select the show string block.

makecode-elecfreaks-oled-07

Place the show string block in the forever block.

makecode-elecfreaks-oled-08

Change the string in the show string block. Run the code.

makecode-elecfreaks-oled-10

Notice how the block repeats the string again and again. To prevent this we will first add a delay. Click on the “Basic” drawer of the Toolbox.

makecode-elecfreaks-oled-11

Select the pause block.

makecode-elecfreaks-oled-12

Place the pause block below the show string block. This will keep the string on the display for the specified value.

makecode-elecfreaks-oled-13

Change the value of the pause block in the dropdown menu.

makecode-elecfreaks-oled-14

We will display the readings every second. This still will not prevent the string from repeating. You will need one more block.

makecode-elecfreaks-oled-15

Click on the “OLED” drawer of the Toolbox.

makecode-elecfreaks-oled-16

Select the clear OLED display block.

makecode-elecfreaks-oled-17

Place the clear OLED display block below the pause block. This will reset the display after it displays the string for one second, eliminating the repeated strings.

makecode-elecfreaks-oled-18