Attiny85 serial error

Hello ,

I need a bit f help to programm an Attiny85 with arduino uno.
I have combined some projects that i found on the internet and I came up with this that works totaly fine with the arduino. But when I try to upload this to the attiny85 , it says :

Board: "ATtiny85 (internal 8 MHz clock)"
sketch_dec31c.ino: In function 'void setup()':
sketch_dec31c:20: error: 'Serial' was not declared in this scope
sketch_dec31c.ino: In function 'void loop()':
sketch_dec31c:53: error: 'Serial' was not declared in this scope

And here is the code.... if anyone can help please reply :wink:

#include <IRremote.h>

int RECV_PIN = 0;
IRrecv irrecv(RECV_PIN);
decode_results results;
unsigned long CurrentValue = 0;
unsigned long StoredCode = 0;
const int buttonPin = 1;
const int ledPin = 2;
const int outputPin = 3;
const int relayPin = 4;
int buttonState = 0;
int RecordState = 0;
int outputState = 1;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();

pinMode(ledPin, OUTPUT);

pinMode(outputPin, OUTPUT);

pinMode(relayPin, OUTPUT);

}

void loop() {

buttonState = digitalRead(buttonPin);

if (irrecv.decode(&results)) {
CurrentValue = (results.value);

if(CurrentValue == StoredCode) {
outputState = !outputState;
}

if (RecordState == 1) {
StoredCode = CurrentValue;
RecordState = 0;
digitalWrite(ledPin, LOW);
Serial.print(StoredCode);
}

irrecv.resume();
}

else
{
CurrentValue = 0;
}

if (buttonState == HIGH) {

while (buttonState == HIGH) {
buttonState = digitalRead(buttonPin);
}

digitalWrite(ledPin, HIGH);
RecordState = 1;

}

if(outputState == 1) {

digitalWrite(outputPin, HIGH);
digitalWrite(relayPin, HIGH);
}
else {
digitalWrite(outputPin, LOW);
digitalWrite(relayPin, LOW);
}

}

There are so many issues... Just 2 big ones

  • You need to download and install a "tiny85" core
  • The ATtiny85 does not have a UART so you have to use SoftwareSerial

I use this core.

Ray
My Projects

mrburnette:
There are so many issues... Just 2 big ones

  • You need to download and install a "tiny85" core
  • The ATtiny85 does not have a UART so you have to use SoftwareSerial

I use this core.

Ray
My Projects

can you improve it? :smiley:

thanos_veggos:
can you improve it? :smiley:

I do IR differently: see this project

Ray

Do a lot of reading about moving to ATTiny from Arduino (UNOs etc).

Lots of stuff available via search.

I may be wrong, but I dont think IRremote will work.