Go Down

Topic: ATtiny85 problem with arduino nano v3.0 (Read 1 time) previous topic - next topic

minoswydis

Dec 25, 2012, 06:43 pm Last Edit: Dec 25, 2012, 07:28 pm by Coding Badly Reason: 1
Hey, I was trying to programme Attiny85 with mine arduino v3.0, and  when i try to test code or upload it to attiny85 i always get error ""serial" was not declared in the scope". Maybe there is some way to fix this or other way to upload this code into attiny85? Please help. Here is code:

Code: [Select]
#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{ pinMode(12, OUTPUT);
 pinMode(13, OUTPUT);
 Serial.begin(9600);
 irrecv.enableIRIn();
}

void loop()
{
 if (irrecv.decode(&results)) {                                                                                                                              
   if (results.value==0x086){digitalWrite(12, HIGH); delay(1000);}  
   if (results.value==0x481){digitalWrite(13, HIGH); delay(1000);}  
   if (results.value==0x886){digitalWrite(12, LOW); delay(1000);}  
   if (results.value==0xC81){digitalWrite(13, LOW); delay(1000);}  
   irrecv.resume();                                                                                
 }
}

and error is looks like this :

'Serial' was not declared in the scope

Code: [Select]
IRrecvDemo_Bulb.ino: In function 'void setup()':
IRrecvDemo_Bulb:12: error: 'Serial' was not declared in this scope



Moderator edit: [code] [/code] tags added.

johnwasser

The ATtiny85 does't have a hardware serial port so the 'core' doesn't include the Serial object.  Since you don't seem to be using the Serial object, just remove "Serial.begin(9600);" from your setup().
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

minoswydis

#2
Dec 25, 2012, 07:19 pm Last Edit: Dec 25, 2012, 07:28 pm by Coding Badly Reason: 1
I did this, and now i get this "error compiling"


Code: [Select]
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp: In member function 'virtual void IRsend::mark(int)':
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:172: error: 'TCCR2A' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:172: error: 'COM2B1' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp: In member function 'virtual void IRsend::space(int)':
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:180: error: 'TCCR2A' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:180: error: 'COM2B1' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp: In member function 'void IRsend::enableIROut(int)':
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:198: error: 'TIMSK2' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:198: error: 'TOIE2' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:207: error: 'TCCR2A' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:207: error: 'WGM20' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:208: error: 'TCCR2B' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:208: error: 'WGM22' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:208: error: 'CS20' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:211: error: 'OCR2A' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:212: error: 'OCR2B' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp: In member function 'void IRrecv::enableIRIn()':
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:224: error: 'TCCR2A' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:229: error: 'TCCR2B' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:229: error: 'CS22' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:230: error: 'CS21' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:231: error: 'CS20' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:234: error: 'TIMSK2' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:234: error: 'TOIE2' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:236: error: 'TCNT2' was not declared in this scope
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp: In function 'void TIMER2_OVF_vect()':
C:\Users\Pukis\Documents\Arduino\libraries\IRremote\IRremote.cpp:266: error: 'TCNT2' was not declared in this scope


Moderator edit: [code] [/code] tags added.

Coding Badly


The IRremote remote library uses timer 2.  The ATtiny85 processor does not have a timer 2.  I have no idea if there is an alternative library.

minoswydis

Than maybe there is other kind of microcontroller that would support these libraries and i could upload programm to it with arduino? :)

dc42

The ATtiny85 is quite capable of being used in an IR remote controller - I've just built a remote using an ATtiny45. It doesn't have timer 2, but it has timers 0 (8-bit) and 1 (16-bit). I used timer 1 to generate the 38kHz signal in my design.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

minoswydis

maybe there is some tutorial how to set my attiny85 to work with timer 1?

johnwasser

If it were me, I'd start by making a copy of the IRremote library and call it IRremoteTiny.  Then change all the references to Timer2 registers to work with Timer1.  That should bring the number of compile errors down to a reasonable number. Debug from there.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

minoswydis

I am new in programming and I don't really know how to change TIMERs in library, i have changed TIMSK2 to TIMSK0 and few others but it doesn't make any good. Maybe someone has IRremote library modified to work with attiny? :/

Erni


minoswydis


Go Up