Pages: [1]   Go Down
Author Topic: Using Serial.begin with ATtiny85  (Read 1008 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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:

Code:
#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: [code] [/code] tags added.
« Last Edit: April 12, 2013, 02:01:48 pm by Coding Badly » Logged

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

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 ?


Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4538
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Yes it is.

The ATtiny85 doesn't have a serial port.
Logged

No, I don't answer questions sent in private messages...

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

Quote
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/


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

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

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4538
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Is he using that core?
Logged

No, I don't answer questions sent in private messages...

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

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

Code:
#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: [code] [/code] tags added.
« Last Edit: April 12, 2013, 02:02:29 pm by Coding Badly » Logged

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 27
Posts: 582
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Pages: [1]   Go Up
Jump to: