Need Help with oled status display project

hello evryone, i want make oled status?condition? display, if something turn on, its displayed on oled ssd1306, when turn off its not displayed on oled (or change of text) but its my first time programing arduino… with xod it’s helping me alot for newcomer… to learn and programing arduino…

(i replace activation sensor with button and will changed with optocoupler when complete)

my problem is, when button pressed the text appear, when released text still apear…

i need condition that when button 1 pressed it apear and button 2 also pressed it also apear, and when button released the the text disapear… (like led indicator but on oled screen with text)

in my design i incorporate xod logo when start booting on… and disapear when status system working…

can anyone help me with this project… thanks you

sorry for bad english…

I think you need to clear the text explicitly when button is released. You can use ‘not’ node for this to a 2nd copy of the draw-text for something like this:


Note that both strings need to be the same length (in this case, I added space at the end of Enabled to make it the same length as Disabled). If the strings are not the same length, the longer string will not be fully erased on change to shorter string.

Alternately, you can change the text that is displayed based on status of button & update on button change (using pulse-on-change node). Something like this:


If text doesn’t seem to update correctly/consistently with this option, you can add a ‘defer’ node between pulse-on-change and draw-text node to make sure draw-text-TEXT updates before UPD gets pulsed. Alternately, it might make more sense to tie pulse-on-change to output of if-else instead of button output (functionally the two will be the same since if-else only change when button changes, but future changes might change that & change of TEXT is when you really need to make the update).


thanks for repply and solution…
the text working but text on top each other… tried “clear-display” after “pulse” but it’s also remove other “status indication”


this one use clear display after pulse, but its remove other status when pressed

You may need to do a clear-display, then re-draw all the status messages. If any of the messages change, you want to clear screen, then pulse UPD on all draw-text nodes.


im use clock as clear display interval, but its doesn’t do “clear-display” at all… maybe something missing for clock to working?

Greetings! Not sure if this will help you, but there is an option to clear some of the text on the screen. To do this, in place of the text that should disappear, I drew a rectangle with a fill and marked the color “0”. As a result, the area of the display covered by the black rectangle was simply erased.

Odd that clear-display using clock ticks doesn’t work if it was working before on button-press… I doubt you really want to do that anyway. You only need to clear when there is an update to be made.


this my solution for my setup… maybe someone have simpler system then me…

1st a style note: when you have a bunch of wires from one pin to many pins all over you patch, it is time to look into using busses. They are basically invisible wires you can label. You can have one to-bus with a given name, and any number of from-buses that use the same name. Given a descriptive name for the wire, it can make your code easier to read and self-documenting…it can also make things hard to trace out if over-used. The balance between the two is going to be a personal choice. As I show below, you can have multiple wires from a from-bus; you don’t need a new from-bus for each input pin that uses them.

Having each line of your display update based on clock ticks seems very inefficient if the display only changes on button presses. There might be other reasons you want to base it on clock tickets, but just to “make sure it updates after button press” is probably not a good reason. Just update entire display if any button is pressed (or you are booting).

Unless you are having the display spin, I don’t think you want to rotate or invert the display on a loop either…seems like things that only need set on boot…

I don’t have hardware to test, but it seems to me something like this should work. If boot or any button pressed, clear display, draw text for each line, then send-buffer.


This is only a part of your code. There might be reasons why my code works for this part, but breaks your program as a whole, so my comments above about your “inefficiencies” might not apply in your case. Sometimes the simplest solution for one part of the program makes the program as-a-whole more complicated; if you don’t use the shortcut for this part, you might be able to reuse code or calculated values for another part of your program.

Back to styling notes: in this case, I only have one from-bus-OLED…it would have been just as easy to use a jumper node in place of the from-bus-OLED to force that wire to the left side of the patch and allow multiple wires to branch from there. A jumper node is just a dummy node that become a part of your wire so it can be pinned to a location to force the wire to route through a specific path, or allow you to branch off at a specific location. The same could be done in your example to force most of the wires to run between nodes instead of through the middle of them and just a couple wires coming off the device node and branching off later.

There are also only one each of B1 & B2 from-bus, but using them allows button code to be split off from display code, making it easier to show control code versus code to just update display. Again…usage will be dependent on personal preference, and is likely to change based on complexity of surrounding code and other factors. Just know that these alternatives are available to help you manage the appearance and readability of your code.

If you are displaying a lot of lines of text, you probably want to change layout so each draw-text node isn’t taking up 2 rows. One option might be to put B2 to the right of the 1st draw-text. It is a little less obvious at first glance what you are doing, but it is more compact, and repeating patterns are easy to parse once you see the pattern.

One advantage of splitting off sections of code (like “update-display”) is that it can be pulled out into your own custom patch so it is not cluttering up your main program. In this case, you could probably create a patch that just needs DEV, each line of text to display, and an UPD pin (and you might not need the UPD pin if you add pulse-on-change nodes to the input pins–it depends how YOU want to use YOUR patch. Moving more inside the patch makes the calling code cleaner, but might remove flexibility you want/need. You can hard-code X,Y,SIZE,COLOUR,WRAP for each line, but that means you need a new patch just to change those values, so it is not likely to be as useful to reuse on your next project. A best-of-both-worlds solution might be to create a generic node that allows you to specify most or all of those values, then write a wrapper for it specific to this project that only has pins for data you change & hard-code the rest of the data into the wrapper.)

If (for example) you had a project with 2 displays showing similar information, it makes even more sense to pull the display code into its own node. Now instead of duplicating the display code, you just duplicate the one node & pass in 2 different DEV values to control the displays separately.

If you want more discussion on style, layout, and encapsulation, my library gweimer/traffic-light-advanced — XOD is an extension on the original traffic light tutorial that explores more XOD features & their usage as well as design/usage considerations and thought processes involved in creating code (like starting simple and building on success; it is REALLY hard to write a complex project that “just works” and trying to jump straight to a completed project is likely to be very frustrating.)

1 Like