1

I have a sketch that prints out a value from 0 to 100. I want it to take up the whole screen.

I can't figure out how to make the font bigger I think that the part of the code defines the size of the font is :

    oled.setFont(System5x7)

But if I alter the value 5x7 it just spits out errors messages.

This is all the code:

#include "SSD1306Ascii.h"
#include "SSD1306AsciiAvrI2c.h"
SSD1306AsciiAvrI2c oled;
#define I2C_ADDRESS 0x3C




int TankValue0;
int TankValue1;

void setup() {
  Serial.begin(9600);
  oled.begin(&Adafruit128x64, I2C_ADDRESS);
  oled.setFont(System5x7);
  oled.clear();
}

void loop() {
  int sensorTankValue0 = analogRead(A0);
  int sensorTankValue1 = analogRead(A1);
  TankValue0 = map(sensorTankValue0, 300, 785, 100, 0);
  TankValue1 = map(sensorTankValue1, 300, 785, 000, 0);
  if (TankValue0 < 0) {
    TankValue0 = 0;
  }
  if (TankValue1 < 0) {
    TankValue1 = 0;
  }
  if (TankValue0 > 100) {
    TankValue0 = 100;
  }
  if (TankValue1 > 100) {
    TankValue1 = 100;
  }
  oled.print(TankValue0);
  oled.print(" L");
  oled.println(" ");
  //oled.print("T1=");
 // oled.print(TankValue1);
 // oled.println(" ");
  oled.setCursor(0, 0);
  delay(1000);
}
3
  • 2
    You can't just choose arbitrary numbers. "System5x7" is the name of a font. You have to look in the library you're using to see what other fonts are available and choose one accordingly.
    – Majenko
    Mar 20 at 13:37
  • 1
    spits out errors messages ... what error messages? ... why do you believe that error messages are useless for determining the source of the problem?
    – jsotola
    Mar 20 at 16:36
  • 1
    As pointed out above "System5x7" is The name of a font that is being used. In this case the 5 and 7 do refer to how many dots are used to make up the output text, but it is just the name of the font it is drawing upon who's code is inside the library-- is this case: "library->SSD1306Ascii->src->fonts" In this folder are many fonts to chose from that one can substitute for "System5x7" for example "fixed_bold10x15". I have not found one that fill the whole screen. Presumably 64x64 would get me both digits. I have explored the font file, but it is beyond me to create one from scratch. Mar 21 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.