Attiny85 Serial sketch error

Hello guys
I'm trying to load a pretty simple sketch on a attiny85 chip. I'm using a mega2560 and I believe all the pins are correct for down loading the sketch. I have already run the blink sketch and it works fine. My next move was to follow the instructions for converting the chip to 8Mhz which also went well. Once again I down loaded blink and a fade sketch and they both worked fine.
Than I tried to compile and load the sketch below and got an error.

"random_move.ino: In function' void loop'();
random_move;24: error: 'Serial' was not declared in this scope

I have read quite a bit in the forms and else where to find this error or see what might cause it. The only thing I've seen is the tinyisp files for I assume allowing use of the serial monitor. I guess my question is does anyone know how to correct this and will the sketch I've written work on the attiny85?
Thanks in advance.

// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!

 
#include <AFMotor.h>
#include <Servo.h>
long randNumber;
const int analogInPin = A2;  // Analog input pin for random
Servo servo1; //= pin D0
Servo servo2; //= pin D1
//----------------------------------------------------
void setup() {
  Serial.begin(9600);
  randomSeed(analogRead(2));  
  servo1.attach(0);          // turn on servo
  servo2.attach(1);
}
//-----------------------------------------------------   
  
void loop() {
  
  randNumber = random(0, 12);  // print a random number from 0 to 11
  Serial.println(randNumber);
  delay(50);
  
  switch (randNumber){          
  case 0:
  Serial.println ("case0");
  servo1.write(140);    // turns servo to 90 deg
  servo2.write(62); 
  delay (4000);
break;

  case 1:
  Serial.println ("case1");
  servo1.write (85);  
  servo2.write(135); 
  delay(4000);
  break;
  
  case 2:
  Serial.println ("case2");
  servo1.write (90);
  servo2.write (140);
  delay(4000);
  break;
  
  case 3:
  Serial.println ("case3");
  servo1.write (95);
  servo2.write (145);
  delay (4000);
  break;
  
  case 4:
  Serial.println ("case4");
  servo1.write (70);
  servo2.write (92);
  delay(4000);
  break;
  
  case 5:
  Serial.println ("case5");
  servo1.write (110);
  servo2.write (140);
  delay (4000);
  break;
  
  case 6:
  Serial.println ("case6");
  servo1.write (70);
  servo2.write (130);
  delay (4000);
  break;
  
  case 7:
  Serial.println ("case7");
  servo1.write (70);
  servo2.write (130);
  delay (4000);
  break;
  
  case 8:
  Serial.println ("case8");
  servo1.write (70);
  servo2.write (130);
  delay (4000);
  break;
  
  case 9:
  Serial.println ("case9");
  servo1.write (70);
  servo2.write (130);
  delay (4000);
  break;
  
  case 10:
  Serial.println ("case10");
  servo1.write (70);
  servo2.write (130);
  delay (4000);
  break;
  
  case 11:
  Serial.println ("case11");
  servo1.write (130);
   delay (100);
  servo2.write (72);
  delay (100);
  servo1.write (70);
   delay (100);
  servo2.write (140);
  delay (100);
  servo1.write (130);
   delay (100);
  servo2.write (72);
  delay (100);
  servo1.write (70);
   delay (100);
  servo2.write (140);
  delay (100);
  servo1.write (130);
   delay (100);
  servo2.write (72);
  delay (100);
  servo1.write (70);
   delay (100);
  servo2.write (140);
  delay (2000);
  break;
    }
  }

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

The core you are using does not support Serial. You have three choices...

  1. Go without
  2. Use a different core (like the one available from here... Google Code Archive - Long-term storage for Google Code Project Hosting.)
  3. Use NewSoftSerial

Thanks for responding Coding Badly!

I purchased 10 of the attiny85's to take the place of the much larger atmega328p which works great for this simple code but I needed the much smaller profile. I followed your post to get this far and it has worked up to this point except of course the serial read. =(
The Code you mentioned below, I was not at all able to get to work before. I will try again using all I've learned about loading the tiny's on your post and see it that helps. I will get back to you shortly.

Coding Badly

I guess this is where I get stupid. The zip file arduino-tiny-0100-0017.zip confuses me as to what folder it's un-ziped files should reside in?
I assumed they were like the core files MIT suggest and reside in a folder named hardware under sketches. "assumed" :~
I also followed the supporting links with Bro Hogan and downloaded TinyWireM.zip, TinyWireS.zip and LiquidCrystal_I2C_85V1.zip to get all the supporting files and make it as functional as possible.

A little direction as to where these files reside will help me figure out how to use them.
Thanks

Coding Badly
I guess this is where I get stupid. The zip file arduino-tiny-0100-0017.zip confuses me as to what folder it's un-ziped files should reside in?
I assumed they were like the core files MIT suggest and reside in a folder named hardware under sketches. "assumed" smiley-confuse
I also followed the supporting links with Bro Hogan and downloaded TinyWireM.zip, TinyWireS.zip and LiquidCrystal_I2C_85V1.zip to get all the supporting files and make it as functional as possible.
A little direction as to where these files reside will help me figure out how to use them.
Thanks

OK moving on
I figured out where and how the zip files needed to be placed under hardware and the others in lib.
Now I have a different issue.

When I went to burn the attiny85 with the new bootloader on the board (attiny85 @8Mhz (internal Oscillator; BOD disabled)
this error showed up. " my documents/arduino/hardware/attiny/bootloaders/empty/empty85at8.hex, no such file exist"
I went to that directory and the file is clearly there with 1k data showing on the folder.
Any ideas why it would stop here?
I seems to be burning fine till it reaches this point.
Rodney

Arduino IDE version?

Arduino 1.0.5

Huh. Of the thousands of people using that core you're the first to have that problem.

" my documents/arduino/hardware/attiny/bootloaders/empty/empty85at8.hex, no such file exist"

Is that the exact error message? No drive-colon in front of the path?

I'm sorry yeah
The drive is in front of the path. Since I had to write the error I figured we didn't need the c:/.
Well yeah that is my luck, nothing I do can be easy. lol
I haven't written anything here yet but I'm having some of the same issues with GPS sample routine. But the error is about uint8_t.
I thought if I cleared up this issue it might fix the other.
Is it possible I have placed some files incorrectly that would cause path issues?

The worst part is I can load sketches to the tiny85 using directions from your post and they run fine. But the fact that I need it to serial.read blows my project.

RodneyD:
But the fact that I need it to serial.read blows my project.

There are no calls to Serial.read in your original sketch so I assumed you would not need it. The Serial that comes with that core is write-only.

Your right - I meant Serial.println.
Is there a way around the need for serial.print.ln to get a random number? I can't think of one short of adding an extra chip and if that's the case I might as well go back to the mega328p.
If you don't have any ideas about how to get around it I will try dumping all of Arduino 1.0.5 and start over to reload the add on files. I'm thinking since like you said thousands of others have no problem with this, it just might be the way it's loaded in the files.
At this point it would be much easier and cleaner to reload it all, and start over than try and find a missing or out of place file.

RodneyD:
The drive is in front of the path. Since I had to write the error I figured we didn't need the c:/.

You do not need to rewrite the error. Use the mouse to select the text the press Ctrl + C to copy. Ctrl + A selects all the text.

RodneyD:
Is it possible I have placed some files incorrectly that would cause path issues?

What you should have done...
• Create a folder named tiny under the {Sketchbook}\hardware folder
• Unzip into {Sketchbook}\hardware\tiny
• Create a boards.txt file
• Copy entries from Prospective Boards.txt into boards.txt

I have the impression that you did all that correctly.

Enable Verbose Output for Uploads. Try again to Burn Bootloader. Use Ctrl + A and Ctrl + C to copy the entire contents of the Status Window into a reply. Please use
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags.

Thank you for the tips. I'm working off two computers but I will move the project to this one so I can do just that. Copy/ paste much easier lol
Yes your right. I did just like you said with the folders.
At first I was all confused but I came across you post later and figured that much out.
Once I did it right, "folders that is" everything started working like the instructions until the error popped up.
I will work on this tonight and post as much as I can to help resolve this in the morning.
BTW I see your in Dallas, just down the road a bit from you in Mid Cites- Hurst.
Rodney

Ok heres what we have so far
I moved all the hardware to desktop computer instead of laptop so I could cut and paste results.

Downloaded from this site : (Google Code Archive - Long-term storage for Google Code Project Hosting.) arduino-tiny-0100-0017.zip
Did just what you instructed here:

• Create a folder named tiny under the {Sketchbook}\hardware folder
• Unzip into {Sketchbook}\hardware\tiny
• Create a boards.txt file
• Copy entries from Prospective Boards.txt into boards.txt

I hooked up to my mega2560 using Arduino 1.0.5 software.
I've loaded the ArduinoISP sketch and changed the lines in the sketch to match mega2560,
#define RESET = 53
#define SCK =52
#define MOSI = 51
#define MISO = 50

Then changed to following settings under tools:
Tools / board mega2560, Com 3, programer avrisp.
Uploaded sketch to mega 2560 "no problems"

Next:
Placed 10pf cap between Gnd and reset on mega2560 "keeping in mind cap + to reset"
Ran jumpers as follows: Pin outs to Attiny85
mega2560 53 to reset 1 tiny85
mega2560 52 to SCK 7 tiny85
mega2560 51 to MOSI 5 tiny85
mega2560 50 to MISO 6 tiny85
tiny85__ 8 to 5+vdc
tiny85__ 4 to 5-vdc

Next:
Changed tools settings:
Tools / board attiny85 @ 8Mhz (internal Oscillator; BOD disabled), Com 3, programer Arduino as ISP.

Next:
Went to Tools/ Clicked on "Burn BootLoader"
It came back with :
Avrdude: Please define PAGEL and BS2 signals in the configuration files for Attiny85.

So it worked using my desk top it appears.

Next:
I went to my sketch folder"code earlier in post" and loaded (random_move) sketch.
Once again I checked Tools setting:
Tools / board attiny85 @ 8Mhz (internal Oscillator; BOD disabled), Com 3, programer Arduino as ISP.

Next I went to the sketch and included library "softwareserial" which placed these two includes in the sketch:
#include <icrmacros.h>
#include <SoftwareSerial.h>

Next I tried to upload the sketch and it came back with the error below:

In file included from random_move.ino:1:
C:\Documents and Settings\dad\My Documents\Arduino\libraries\SoftwareSerial/icrmacros.h:66:2: error: #error This processor is not supported by SoftwareSerial
In file included from random_move.ino:2:
C:\Documents and Settings\dad\My Documents\Arduino\libraries\SoftwareSerial/SoftwareSerial.h:95: error: conflicting return type specified for 'virtual void SoftwareSerial::write(uint8_t)'
C:\Documents and Settings\dad\My Documents\Arduino\hardware\Tiny\cores\tiny/Print.h:73: error: overriding 'virtual size_t Print::write(uint8_t)'

Ok now I'm getting some where showing you the error. :~
Did I down load the wrong file; NewSoftSerial11, I placed this download in the folder Arduino/libraries/

let me know what other info I can give.
Rodney

Or just try softwareserial library - it works great on the ATtiny85

Hello TheKitty

Thanks for the advice, but as I stated above; I did use that library and the results are posted there also.
If you have some knowledge about these files that could help resolve this I would love some direction.
Thanks again Rodney

I don't understand why you include #include <AFMotor.h> when you dont use it

#include <Servo.h>

There is a special servolib for the ATtiny85/45

http://www.cunningturtle.com/attiny4585-servo-library/

And finally, try to test just the SoftwareSerial

#include <SoftwareSerial.h>

#define rxPin 3
#define txPin 4

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

int x=0;
void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);

  mySerial.begin(9600);
}

void loop() {

  mySerial.print("Test...");
  mySerial.println(x);
  delay(1000);
}