need help with fixing code for an attiny85

Hi I’m using an attiny85 as standalone. The bootloader is burned on it successfully and yes I know the pins arent set up for attiny85 because the numbers are too high but I’ve already tried changing them to the correct pins. The issue is, I keep getting a a red highlight over: Serial.begin(9600);
Everything else works fine I know because it has already been successfully uploaded to a atmega328p standalone and tested.

I’m kind of a beginner in coding.
how do I stop Serial.begin(9600); from being highlighted. What would I need to change to fix this

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <gfxfont.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 12
const byte buttonpin = 3;
const byte pinny = 2;


Adafruit_SSD1306 display(OLED_RESET);

static const unsigned char PROGMEM Logo[] = //128x64 bitmap
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFE, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x1F, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xF9, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x39, 0xCF, 0xE7, 0xFF, 0xFF,
0xFF, 0xFF, 0xF0, 0x01, 0xCF, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0x0F, 0x87, 0xFF, 0xFF,
0xFF, 0xFF, 0xFC, 0x20, 0x04, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x7F, 0xFF, 0xFF,
0xFF, 0xFF, 0xFC, 0xC0, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xE0, 0x07, 0x0F, 0xFF, 0xFF,
0xFF, 0xFF, 0xF3, 0x00, 0x80, 0x67, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x09, 0xC8, 0x07, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xF9, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x9F, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFC, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  };

void setup()   
{                
  pinMode(13, OUTPUT);
  
  pinMode(pinny, INPUT_PULLUP);
  // initialize with the I2C addr 0x3C / mit I2C-Adresse 0x3c initialisieren
  display.begin(SSD1306_SWITCHCAPVCC, 0x3c);


  pinMode(buttonpin, INPUT_PULLUP); 
  // initialize with the I2C addr 0x3C / mit I2C-Adresse 0x3c initialisieren
  display.begin(SSD1306_SWITCHCAPVCC, 0x3c);
  
  Serial.begin(9600);// <-------------THIS IS WHATS HIGHLIGHTED RED> HOW TO FIX?

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  // init done
  
  display.clearDisplay();
  display.display(); // show splashscreen
  delay(2000);
  display.clearDisplay();   // clears the screen and buffer
 
  display.setTextColor(INVERSE);
  
  display.drawBitmap(31, 8,  Logo, 64, 32, 1);
  display.display();
  delay(6000);
  display.clearDisplay();
  display.drawBitmap(0, 0,  Logo, 0, 0, 0);
  display.display();
  delay(1000);
  display.clearDisplay();
  
} 

void loop() 
{ 
  if (digitalRead(buttonpin) == LOW)
     {
       display.clearDisplay();
       display.setCursor(41,20);
       display.setTextSize(1);
       display.print("");
       display.setCursor(32,20);
       display.setTextSize(0);
       display.print("Goodbye");
     }
     else
     {
       display.clearDisplay();
     }
       
     display.display();
    {
      if (digitalRead(pinny) == LOW)
     {
       display.clearDisplay();
       display.setCursor(41,20);
       display.setTextSize(1);
       display.print("");
       display.setCursor(32,20);
       display.setTextSize(0);
       display.print("Hello");
     }
     else
     {
       display.clearDisplay();
     }
       
     display.display();
    }
}

ATtiny85 doesn't have a hardware serial port so it's not surprising that you would get an error for that line. It is possible to create a software serial port if you need serial communication. If you use ATTinyCore, it actually uses software serial for the Serial object on the ATtiny85, which would allow that sort of code to compile: https://github.com/SpenceKonde/ATTinyCore#serial-support

Hi I’m using an attiny85 as standalone. The bootloader is burned on it successfully and yes I know the pins arent set up for attiny85 because the numbers are too high but I’ve already tried changing them to the correct pins. The issue is, I keep getting a a red highlight over: Serial.begin(9600);
Everything else works fine I know because it has already been successfully uploaded to a atmega328p standalone and tested.

I’m kind of a beginner in coding.
how do I stop Serial.begin(9600); from being highlighted. What would I need to change to fix this

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <gfxfont.h>
#include <Adafruit_SSD1306.h>

#define OLED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, 0xFF,
0xFF, 0xFF, 0xFF, 0xF9, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x9F, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFC, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  };

void setup()   
{                
  pinMode(13, OUTPUT);
  
  pinMode(pinny, INPUT_PULLUP);
  // initialize with the I2C addr 0x3C / mit I2C-Adresse 0x3c initialisieren
  display.begin(SSD1306_SWITCHCAPVCC, 0x3c);


  pinMode(buttonpin, INPUT_PULLUP); 
  // initialize with the I2C addr 0x3C / mit I2C-Adresse 0x3c initialisieren
  display.begin(SSD1306_SWITCHCAPVCC, 0x3c);
  
  Serial.begin(9600);// <-------------THIS IS WHATS HIGHLIGHTED RED> HOW TO FIX?

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  // init done
  
  display.clearDisplay();
  display.display(); // show splashscreen
  delay(2000);
  display.clearDisplay();   // clears the screen and buffer
 
  display.setTextColor(INVERSE);
  
  display.drawBitmap(31, 8,  Logo, 64, 32, 1);
  display.display();
  delay(6000);
  display.clearDisplay();
  display.drawBitmap(0, 0,  Logo, 0, 0, 0);
  display.display();
  delay(1000);
  display.clearDisplay();
  
} 

void loop() 
{ 
  if (digitalRead(buttonpin) == LOW)
     {
       display.clearDisplay();
       display.setCursor(41,20);
       display.setTextSize(1);
       display.print("");
       display.setCursor(32,20);
       display.setTextSize(0);
       display.print("Goodbye");
     }
     else
     {
       display.clearDisplay();
     }
       
     display.display();
    {
      if (digitalRead(pinny) == LOW)
     {
       display.clearDisplay();
       display.setCursor(41,20);
       display.setTextSize(1);
       display.print("");
       display.setCursor(32,20);
       display.setTextSize(0);
       display.print("Hello");
     }
     else
     {
       display.clearDisplay();
     }
       
     display.display();
    }
}

Attiny85 doesn't have a serial usart. There is no Serial. So you'll have to change to using software serial or switch to a chip where it exists.

DON'T CROSS POST!!!!!!!!!!!!!!!!!!!! http://forum.arduino.cc/index.php?topic=579716 I HAVE REPORTED THIS THREAD TO THE MODERATORS

Why would you create a new thread when someone is already trying to help you in the original thread?

Duplicate posts waste the time of the people helping you. I might spend 15 minutes writing a detailed answer on this thread, without knowing that someone already did the same in the other thread. This behavior is very disrespectful to the people you're asking for assistance. Just because we give our time freely doesn't mean it has no value.

In the future, take some time to pick the forum section that best suits the topic of your question and then only post once to that forum section. This is basic forum etiquette, which you would already know if you had bothered reading the sticky "How to use this forum - please read." post you will find at the top of every forum section. It contains a lot of other useful information. Please read it.

Which tiny 85 core are you using? Do you know that the tiny85 processor has no hardware serial?

When compiled for an Uno I get:

Sketch uses 10892 bytes (33%) of program storage space. Maximum is 32256 bytes. Global variables use 982 bytes (47%) of dynamic memory, leaving 1066 bytes for local variables. Maximum is 2048 bytes.

The tiny85 processor has 512 bytes of SRAM and 8K bytes of flash. Might have a problem there even after you fix the pins.

The ATTiny core lets you use Serial, It automatically substitutes software serial for serial.

On the following chips, no hardware serial is available, however, a built-in software serial named Serial is provided to maximize compatibility. This uses the analog comparator pins (to take advantage of the interrupt, since very few sketches/libraries use it, while lots of sketches/libraries use PCINTs). TX is AIN0, RX is AIN1 - This is a software implementation - as such, you cannot receive and send at the same time. If you try, you'll get gibberish, just like using SoftwareSerial.

ATtiny x5 (25/45/85)

DON'T CROSS POST!!!!!!!!!!!!!!!!!!!! http://forum.arduino.cc/index.php?topic=579716 I HAVE REPORTED THIS THREAD TO THE MODERATORS What are you doing? I tried to help you the first time you posted this. Then I told you not to cross post the second time you posted this. Now you post the third time? This sort of behavior will get you nowhere on this forum. I know I won't be motivated to help you in the future.

Duplicate posts waste the time of the people helping you. I might spend 15 minutes writing a detailed answer on this thread, without knowing that someone already did the same in the other thread. This behavior is very disrespectful to the people you're asking for assistance. Just because we give our time freely doesn't mean it has no value.

In the future, take some time to pick the forum section that best suits the topic of your question and then only post once to that forum section. This is basic forum etiquette, which you would already know if you had bothered reading the sticky "How to use this forum - please read." post you will find at the top of every forum section. It contains a lot of other useful information. Please read it.

Where my post go? Oh well....

how do I stop Serial.begin(9600); from being highlighted.

Pretty simple, really. Don’t call a function that is not supported.

Where my post go? Oh well....

Mine, too?

Delta_G: Where my post go? Oh well....

groundFungus: Mine, too?

Over zealous moderator.

@Zackypoo, you cross-post again you go bye-bye.

Sorry I wasn't trying to crosspost. Some people need to chill out. I was re-editing my stuff. I unknowingly re-made it 3 times. The first time I couldn't find my original post, because I was accidentally looking in the wrong section and so I posted again. I don't know what happened the third time. I'm still slightly new to the forum thing so take it easy. But anyways, aside from that, Thank you guys for the info. I very much appreciate it. I assumed maybe it did have a serial port because I saw people use attiny85 with the OLED display before, but I guess not. Also, the people who say use different pins numbers, I've already tried and the same message "Serial.begin(9600); was not declared shows up". I'll try changing the pin numbers around some more but if it doesn't work I'll just take the word from the other guys that it's because of the lack of serial ports, after that I'm moving on, I'm on a time schedule for this. Again thanks!

If you are using my core, there is a software serial port built-in to the core called Serial, for ease of porting sketches between ATMega and the ATTiny85 (note that it is a software serial port, see the core documentation https://github.com/SpenceKonde/ATTinyCore#serial-support for caveats when working with software serial).

Since you're getting Serial was not declared, I conclude that you are not using my core.

You're going to have another problem though - once you remove serial, you'll discover that SPI.h won't compile because the ATtiny85 doesn't have SPI. Though my core also has a solution for that with universal Wire and SPI libraries that select the correct implementation of SPI/I2C for the selected chip, so you can usually use the same code and libraries that you would on a normal Arduino. Even so, you may still have a problem, because LCD drivers are notorious flash/ram hogs, and you may find that the tiny85 doesn't have enough flash and/or RAM for it.

Installation instructions for my core: https://github.com/SpenceKonde/ATTinyCore/blob/master/Installation.md

Zackypoo: Sorry I wasn't trying to crosspost. Some people need to chill out. ...

Some people need to read How to use this forum - please read. It talks about the problems associated with posting multiple times. If you lose your posts, just click the "Profile" link under your icon in the upper right of the window. Click where it says "EDIT" forum settings, and then you'll see a link on the left center that shows you all your posts.

Bear in mind that the people you are telling to "chill out" are helping you for free, and you have created a situation where it looks to them like a moderator has deleted their posts. Read the guidelines, and you'll find folks here so much friendlier.

ChrisTenone: Bear in mind that the people you are telling to "chill out" are helping you for free...

...and have to, occasionally, endure those who are helped lying about the circumstances. I presume it is a childish attempt to deflect the transgression while making the moderators out to be jerks.

In any case ... thread locked. This "discussion" has reached the end.