Pages: [1]   Go Down
Author Topic: ATtiny85 problem with arduino nano v3.0  (Read 1104 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
IRrecvDemo_Bulb.ino: In function 'void setup()':
IRrecvDemo_Bulb:12: error: 'Serial' was not declared in this scope


Moderator edit: [code] [/code] tags added.
« Last Edit: December 25, 2012, 01:28:26 pm by Coding Badly » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8695
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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().
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I did this, and now i get this "error compiling"


Code:
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.
« Last Edit: December 25, 2012, 01:28:45 pm by Coding Badly » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 199
Posts: 12768
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8695
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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? :/
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1057
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe this one :

http://blog.tkjelectronics.dk/2012/03/attinyremote/
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

THX but this didn't help :/
Logged

Pages: [1]   Go Up
Jump to: