Im trying to compile a script and i get the error "serial does not name a type" and the line Serial.begin(9600); gets highlighted. The script is one for displaying to an Oled which i butchered from an example script because i was just wanting the bit in the script which out puts a value (which I'm taking from a GPS unit)
The script is from the Makerhawk Oled example library.
I cant re run the compiling of the script because i don't have my first attempt at editing out all the stuff from the old example script. This is because i think the script became autosave as i messed with it further to try and fix it so my original question is redundant now. Sorry.
My latest attempt to extract a hello world script from the example script is the following.
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0, 0); // Start at top-left corner
display.println(F("Hello, world!"));
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); // Draw 'inverse' text
display.println(3.141592);
display.setTextSize(2); // Draw 2X-scale text
display.setTextColor(SSD1306_WHITE);
display.print(F("0x")); display.println(0xDEADBEEF, HEX);
display.display();
delay(2000);
}
}
This, of course does not compile either getting an error "display does not name a type" and the line "display.display();" is highlighted as the problem line.
I think I'm just down a rabbit hole of endlessly trying to correct something i don't understand.
All I'm trying to do is get some code I can use to display some output from some values I get from a GPS unit.