Using Serial.begin with ATtiny85

Hi peeps,
my first attempt at programming an Arduino, so please make it simple for me.......... :slight_smile:

I have eventually managed to get some code working fine on the Arduino Uno, and have managed to program an ATtiny 85 with some simpler code using the Arduino as ISP...... but when I transfer the full code (excerpt below) to the ATTiny85 it stops at the Serial.begin(9600);
saying that 'serial was not declared in this scope'
HELP please:

#include<multiCameraIrControl.h>
Sony A900(0); //changed pin number from 9

#define RX_SIGNAL_IN 0 
#define RX_SIGNAL_IN_PIN 1 //changed pin number from 2 

#define NEUTRAL_RX 1500 
volatile int nRXIn = NEUTRAL_RX; 
volatile unsigned long ulStartPeriod = 0; 
volatile boolean bNewRXSignal = false; 

void setup()
{
  
  attachInterrupt(RX_SIGNAL_IN,calcInput,CHANGE);

  Serial.begin(9600); 
}

void loop()
{
 
 if(bNewRXSignal)
 {
   
 if(nRXIn >1600)
{

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

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

I don't think your problem is the Serial.begin(9600);

It is more likely the multiCameraIrControl library you include.

Where did you get it ?

Erni:
I don't think your problem is the Serial.begin(9600);

Yes it is.

The ATtiny85 doesn't have a serial port.

Yes it is.

The ATtiny85 doesn't have a serial port.

This sketch wil work perfectly well on a Attiny85.
It use TinyDebugSerial, which is part of this core:

https://code.google.com/p/arduino-tiny/

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

void loop() {
Serial.println("Testing..");
}

Erni:
This sketch wil work perfectly well on a Attiny85.
It use TinyDebugSerial, which is part of this core:

Is he using that core?

fungus:

Erni:
I don't think your problem is the Serial.begin(9600);

Yes it is.

The ATtiny85 doesn't have a serial port.

THanks.! I just removed the serial.begin line and it still all works fine on the arduino (as I don't want to see the serial data)...( this is to control an infrared LED that triggers a Sony camera) it goes in to the ATtiny85 OK, but works very erratically.....responding randomly to the R/C input signal....and sensitive to fingers placed near!
I added some code to (I think) specify the correct pins on the ATtiny..excerpt below

#include<multiCameraIrControl.h>
Sony A900(0);

#define RX_SIGNAL_IN 0 
#define RX_SIGNAL_IN_PIN 1 

#define NEUTRAL_RX 1500 
volatile int nRXIn = NEUTRAL_RX; 
volatile unsigned long ulStartPeriod = 0; 
volatile boolean bNewRXSignal = false; 

void setup()
{
  pinMode(1,INPUT);
  pinMode (0,OUTPUT);
  attachInterrupt(RX_SIGNAL_IN,calcInput,CHANGE);

  }

void loop()
{
 
 if(bNewRXSignal)
 {
   
 if(nRXIn >1600)
{ 
   A900.shutterNow();
  delay(2000);  //time in mS between still photos
}

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

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

You are probably picking up RF interference on your input port. You should add a 0.1 uF ceramic decoupling capacitor to the ATtiny85 Vcc and GND pins. Also you may need to add a pull up or pull down resistor to the input pin to avoid stray signal interference.