Thank you very mutch MaxGerhardt !
I really appreciate your speed to reply! and now its working !
now i have another problem i realize that platformio has problems interpreting functions that are used in loop function for example in this code:
//To use the OLED we need to include the following libraries
#include "Arduino.h"
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//We then need to define the pins we are using on the Arduino
#define OLED_DC 11
#define OLED_CS 12
#define OLED_CLK 10
#define OLED_MOSI 9
#define OLED_RESET 13
//#define LOGO16_GLCD_HEIGHT 16
//#define LOGO16_GLCD_WIDTH 16
static const unsigned char PROGMEM battery[] =
{
B00000000, B00000000, B00000000,
B00011100, B00000000, B01110000,
B00011100, B00000000, B01110000,
B01111111, B11111111, B11111110,
B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111,
B11111111, B11111111, B11101111,
B11111111, B11111111, B11101111,
B11000001, B11111111, B10000011,
B11111111, B11111111, B11101111,
B11111111, B11111111, B11101111,
B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111,
};
//Initialize the display
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
//Initialise the sensor input and pressure variable in PSI for the displa
float val = 0;
float voltage = 0;
int x = 5; //digit display centring variable.
int limit = 15; //pressure limit
float z = 10.13; // Analog read divider (1024 / 10.13 = 100 steps)
float z1 = 10.13; // bar graph divider (check because I am not 100% sure)
//Set up the following
void setup()
{
Serial.begin(9600); //To comunicate with the PC
display.begin(SSD1306_SWITCHCAPVCC); //To supply the 3.3V power supply
pinMode(0, INPUT); //Set analog pin 0 as an input from the sensor
display.clearDisplay(); //Clear the display and ram
delay(100);
display.display(); //Show the cleared display to prevent for a smooth transition
delay(100);
}
void loop()
{
val = (analogRead(0) / z1); // bar graph variable
voltage = ((analogRead(0) / z)+8);
drawOILPRESS(); //This runs the command specified below inside the loop
}
void drawOILPRESS(void)
{
display.setTextColor(WHITE);
display.setTextSize(5);
// check value of pressure and centre display based on that value
if (voltage < 10)
{
x = 18; // single digit position
}
else if (voltage < 100)
{
x = 18; // double digit position
}
else
{
x = 18; // triple digit position
}
;
// Print to screen.
display.setCursor(x, 0);
display.println(voltage);
display.setTextSize(1);
display.setCursor(80, 38);
display.println("VOLTS");
display.drawRect(10, 49, 102, 15, 1); //Border of the bar chart
display.fillRect(11, 50, val, 13, WHITE); //Draws the bar depending on the sensor value
// Draw limit line on bar graph display
if (voltage >= limit)
{
display.drawLine((limit + 10), 49, (limit + 10), 63, 0); // black limit line on bar graph
}
if (voltage <= limit)
{
display.drawLine((limit + 10), 49, (limit + 10), 63, 1); // white limit line on bar graph
display.setTextSize(1);
display.setCursor(50, 53);
display.println("ALARM"); // print "ALARM" on display if below limit value.
}
display.drawBitmap(13, 26, battery, 24, 16, 1);
display.display();
display.display();
display.clearDisplay();
delay (100); //delay loop to slow down update speed
}
drawOILPRESS(); This runs the command specified below inside the loop but when i compinling in platformio i have this :
Same error in this code :
#include “SPI.h”
#include “Wire.h”
#include “Adafruit_GFX.h”
#include “Arduino.h”
#include “Adafruit_SSD1306.h”
//
#define OLED_RESET 4
Adafruit_SSD1306 Display(OLED_RESET);
int r = 0;
int i = 0;
void setup() {
Display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
Display.display();
delay (1000);
DrawTitles();
}
void loop() {
// get some dummy data to display
r = rand() / 220;
//r = analogRead(ADJ_PIN);
//r = r / 7.98;
Display.setTextSize(1);
// note set the background color or the old text will still display
Display.setTextColor(WHITE, BLACK);
Display.setCursor(0, 33);
Display.println(Format(r * 7.99 / 204.6, 3, 2));
//draw the bar graph
Display.fillRect(r, 50, 128 - r, 10, BLACK);
Display.fillRect(3, 50, r, 10, WHITE);
for (i = 1; i < 13; i++) {
Display.fillRect(i * 10, 50, 2, 10, BLACK);
}
Display.display();
}
void DrawTitles (void) {
Display.setTextSize(1);
Display.setTextColor(WHITE);
Display.setCursor(0, 0);
Display.println("ENCODERS TST");
Display.setTextSize(1);
Display.setTextColor(WHITE);
Display.setCursor(0, 19);
Display.println("Bargraph.ino0.0");
Display.display();
}
String Format(double val, int dec, int dig ) {
int addpad = 0;
char sbuf[20];
String fdata = (dtostrf(val, dec, dig, sbuf));
int slen = fdata.length();
for ( addpad = 1; addpad <= dec + dig - slen; addpad++) {
fdata = " " + fdata;
}
return (fdata);
}

should I be able to download other extention to implement a vscode so that it matches the arduino environment?
cause in Arduino IDE compiling perfectly…