ATTiny85 serial communication

I am trying to get my ATTiny85 to send serial messages through my Arduino Mega to my pc, but it isn't working. I don't get anything but if I send a command I get 'ÿ' returned. I am trying to follow this tutorial. I am guessing it's something to do with the fuses which are set (to save energy when not bleeping), but I don't know how to unset them - I have tried re-burning the bootloader and commenting out the fuse set lines and the problem was not resolved.
Here is my code:

#include <SoftwareSerial.h>

#include <avr/sleep.h>
#include <avr/power.h>

int PIEZO = 0;
int LED = 1;
#define WDTCR_REG WDTCR

volatile long watchdog_counter = 0;


void setup(void)
{
  Serial.begin( 9600 );
  Serial.println("starting...");
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  
  ADCSRA &= ~(1<<ADEN); //Disable ADC
  ACSR = (1<<ACD); //Disable the analog comparator
  DIDR0 = 0x3F; //Disable digital input buffers on all ADC0-ADC5 pins
  
  setup_watchdog(7);
 
  pinMode(PIEZO, OUTPUT);
  pinMode(LED, OUTPUT);
  annoy();
}

void loop()
{
  sleep_enable();
  sleep_mode();
  
  if (watchdog_counter >= 10) {
    watchdog_counter = random(3);
    annoy();
  }
}

void annoy() {
  Serial.println("annoying");
  digitalWrite(LED, HIGH);
  tone(PIEZO, random(5000, 12000));
  delay(500);
  noTone(PIEZO);
  digitalWrite(LED, LOW);
}


void setup_watchdog(int ii) {

  byte bb;
  int ww;
  if (ii > 9 ) ii=9;
  bb=ii & 7;
  if (ii > 7) bb|= (1<<5);
  bb|= (1<<WDCE);
  ww=bb;

  MCUSR &= ~(1<<WDRF);
  // start timed sequence
  WDTCR_REG |= (1<<WDCE) | (1<<WDE);
  // set new watchdog timeout value
  WDTCR_REG = bb;
  WDTCR_REG |= _BV(WDIE);
}


ISR(WDT_vect) {
  watchdog_counter++;
}

Can anyone help?

Is this supposed to be the Mega code or the ATTiny85 code?

int PIEZO = 0;
int LED = 1;
  pinMode(PIEZO, OUTPUT);
  pinMode(LED, OUTPUT);

On the Mega, those are the Serial pins.

#include <SoftwareSerial.h>

Why? You never create an instance.

The softwareserial is left over from a previous attempt- I will remove it :wink:
The program is for the ATTiny, pins 0 and 1 in software are 5 and 6 on the actual device

The softwareserial is left over from a previous attempt- I will remove it

Don't. You need it. The ATTiny85 doesn't have a hardware serial port.

You definitely need the SoftwareSerial library for the ATTiny85, as PaulS said. You also need to create an instance of SoftwareSerial in your sketch and then use that instance to output, rather than the built in Serial object, like this:

#include <SoftwareSerial.h>
// Define pins
int rxPin = 2;
int txPin = 3;

SoftwareSerial mySerial(rxPin, txPin);

void setup() 
{
  mySerial.begin(9600);
}

A couple of other things to check:

  • Confirm that you have set-up the ATTiny85 to work at 8MHz, as that is needed by the SoftwareSerial library.
  • Make sure you have correctly defined the ATTiny85 pins in the begging of the sketch (the rxPin and txPin in the sample code above) and they match your wiring set-up.

Check the SoftwareSerial library page for more info:

OK, having looked at it I figured out that there are a few problems. I decided to follow this tutorial instead, but I have a problem: I can't use an Arduino Mega 2650 with TinyISP. What can I do to fix this?
Thanks for all your help so far!