Page 1 of 2

Analog value with I2C display ssd1306

Posted: Thu Oct 09, 2025 12:34 pm
by JulianL
Hello,

I would like to ask for your help.
I am using Flowcode together with an Arduino and would like to read in an analog value and display it on an I2C SSd1306 display.
Problem: No permanent value is displayed.
You can find my program in the attachment.

Thank you for your help.

Re: Analog value with I2C display ssd1306

Posted: Thu Oct 09, 2025 12:54 pm
by mnfisher
You are constantly updating the display in a loop - this means it will refresh very rapidly probably with slightly different values.
Try adding a delay.

Also - if the value's representation changes in length (say '10' then '9') - it will not clear trailing digits. One way round this is to convert the value to a string and append some spaces.

.str = ToString$(.value)
.str = .str + ' '
Display(.str) (PrintString from memory)

where .str is a (in this case local variable) declared as a string.

Martin

Re: Analog value with I2C display ssd1306

Posted: Thu Oct 09, 2025 1:28 pm
by medelec35
Hello.
In addition to Martin's reply, with he print function you need to have the Transparency Set to 0 and not 1.
This will make sure that that in the same location, the previous digit is overwritten.
What you are showing is all previous digits in the same location remaining.
That will prevent you from seeing what the current digit is.

Re: Analog value with I2C display ssd1306

Posted: Fri Oct 10, 2025 11:53 am
by JulianL
Hello,

Thanks for your help.

@Martin: Could you show me an example program for your idea using a flowchart? I don't quite understand how I can implement it.

Best regards, Julian

Re: Analog value with I2C display ssd1306

Posted: Fri Oct 10, 2025 8:21 pm
by mnfisher
Hi Julian,

Something like this - it runs AOK in simulation - in hardware you might need to check the pins used (C0 for ADC for example)

Adding a SetFontScaler(2,2) makes the display easier to read! (from the gLCD component)

Martin

Re: Analog value with I2C display ssd1306

Posted: Wed Oct 15, 2025 12:06 pm
by JulianL
Hello,

Thanks for your help.

@Martin: Could you show me an example program for your idea using a flowchart? I don't quite understand how I can implement it.

Best regards, Julian

Re: Analog value with I2C display ssd1306

Posted: Fri Oct 17, 2025 5:55 pm
by xiran
Hi!

I´m new in FC, i´ve come from niple soft, stm32 and pi pico.

I´ve download the file that mnfisher upload, when i´ve try to compile, it says error:

Unknown or missing component: Potentiometer1::GetByte()

Do you know why?


Thx!

Re: Analog value with I2C display ssd1306

Posted: Mon Oct 20, 2025 9:02 am
by medelec35
Hello.
For some reason during Flowcode setup the components did not get copied from the DefaultData folder.
I would suggest to run Flowcode, so you see the NEW PROJECT & OPEN PROJECT splash screen.
Select library Updates.
If you do have components shown within the window, select download
Now you can open your project and check Component Libraries ribbon > Inputs > Analogue Inputs for the Potentiometer [2D]
If you can't see the potentiometer, then make sure the Show Components just below File is set to show 2D and 3D.
Look on the 2D Panel as it will have two components placed on it.
gLCD and Potentiometer.
let me know if that still is not the case.

Re: Analog value with I2C display ssd1306

Posted: Tue Oct 21, 2025 6:44 pm
by xiran
Thx for answer Martin!

I´m using C code, and a pic12f675, founded how to run with ssd1306, the example that i´ve found, it´s a volmeter, but i want to made a Resistometer, =).

The mats are:

volt=((unsigned int)ADRESH*256 + ADRESL)*5;

And i´ve add:

res= ((330 * volt) /(5 - volt));

But the value res showed is 0000 in oled...

Volt is correctly showed

Thx again!

Re: Analog value with I2C display ssd1306

Posted: Wed Oct 22, 2025 8:35 am
by medelec35
You're welcome
you can use the built in potentiometers if you now have them.
The reason 0 is shown would be down to typecasting.
If res variable is a float
Try res = ((330.0 * volt) / (5.0 - volt))
If you have an int or byte variable first, then an explicit Type cast is required before the variable.
E.g. ((FLOAT volt 330.0 * ) / (5.0 - volt))
For typecasting see this Wiki page