Attiny 85 with SoftwareSerial library

and you might be able to find a newer version of SoftwareSerial.

Like the one that ships with 1.0+.

PaulS:

and you might be able to find a newer version of SoftwareSerial.

Like the one that ships with 1.0+.

Well, I tried it with arduino 1.0.5. I get this problem. So I could not figure out what is the problem exactly :frowning:

Vincent19:
Well, I tried it with arduino 1.0.5. I get this problem. So I could not figure out what is the problem exactly :frowning:

Do you have your own version of SoftwareSerial sitting in your hardware directory in the sketchbook? I believe that would preempt the system one.

MichaelMeissner:

Vincent19:
Well, I tried it with arduino 1.0.5. I get this problem. So I could not figure out what is the problem exactly :frowning:

Do you have your own version of SoftwareSerial sitting in your hardware directory in the sketchbook? I believe that would preempt the system one.

What do you mean by own version of SoftwareSerial ?

Thanks !

Vincent19:
What do you mean by own version of SoftwareSerial ?
Thanks !

If you load a board support package for a processor, it includes files that override the standard definition for header files. If that board support package was built a few years ago and targeted the older release of the Arduino IDE, it would bring in the standard print header file, and one function (write) changed to have a different calling sequence. So I imagine if you look around for a newer version of the board support package, and replace your version with the newer one, it may work better.

Similarly, in your sketchbook directory you can have two directories (libraries and hardware) that are searched before the standard versions.

MichaelMeissner:

Vincent19:
What do you mean by own version of SoftwareSerial ?
Thanks !

If you load a board support package for a processor, it includes files that override the standard definition for header files. If that board support package was built a few years ago and targeted the older release of the Arduino IDE, it would bring in the standard print header file, and one function (write) changed to have a different calling sequence. So I imagine if you look around for a newer version of the board support package, and replace your version with the newer one, it may work better.

Similarly, in your sketchbook directory you can have two directories (libraries and hardware) that are searched before the standard versions.

What I found so far is that, no new softwareserial. Newsoftserial == softwareserial for arduino 1.0 and above.

Any advice ?

Are you sure that this version of SoftwareSerial you are using, is from Arduino 1..0.x ?

C::\Program Files(x86)\Arduino\libraries\SoftwareSerial/SoftwareSeial.h

Try to replace it and the coresponding .cpp file with the ones that comes with 1.0.x

Erni:
Are you sure that this version of SoftwareSerial you are using, is from Arduino 1..0.x ?

C::\Program Files(x86)\Arduino\libraries\SoftwareSerial/SoftwareSeial.h

Try to replace it and the coresponding .cpp file with the ones that comes with 1.0.x

I downloaded Arduino V1.0.5. So i think the SoftwareSerial is the newest version.

Any advice ?

Thank yo.

C::\Program Files(x86)\Arduino\libraries\SoftwareSerial/SoftwareSeial.h

This looks like a user-downloaded library file, not the core library file. If is IS a user-downloaded library location, delete the SoftwareSerial directory.

PaulS:

C::\Program Files(x86)\Arduino\libraries\SoftwareSerial/SoftwareSeial.h

This looks like a user-downloaded library file, not the core library file. If is IS a user-downloaded library location, delete the SoftwareSerial directory.

But it come along when I download the arduino 1.0.5 file. Why you would say that it is user-downloaded library file ?

Thanks!

But it come along when I download the arduino 1.0.5 file. Why you would say that it is user-downloaded library file ?

Because the install path for the Arduino IDE and related code usually has the version number in the path. The sketch directory usually does not. Therefore, when I see a path without a version number, I assume that it is a sketch directory, and that is where user-downloaded libraries go. There are good reasons for following conventions.

PaulS:

But it come along when I download the arduino 1.0.5 file. Why you would say that it is user-downloaded library file ?

Because the install path for the Arduino IDE and related code usually has the version number in the path. The sketch directory usually does not. Therefore, when I see a path without a version number, I assume that it is a sketch directory, and that is where user-downloaded libraries go. There are good reasons for following conventions.

So what should I do now ? Redownload the IDE ?

Thank you

So what should I do now ? Redownload the IDE ?

Instead of telling us whether or not that directory really is your sketch directory? I can't see how downloading the IDE again will be a satisfactory alternative.

If that IS your sketch directory, downloading the IDE again will leave it exactly the same, so your problem won't have gone away. Again, I don't see downloading the IDE again as a useful thing to do.

If that IS your sketch directory, deleting the SoftwareSerial folder WILL solve your problem.

But, it's your decision as to what to do.

PaulS:

So what should I do now ? Redownload the IDE ?

Instead of telling us whether or not that directory really is your sketch directory? I can't see how downloading the IDE again will be a satisfactory alternative.

If that IS your sketch directory, downloading the IDE again will leave it exactly the same, so your problem won't have gone away. Again, I don't see downloading the IDE again as a useful thing to do.

If that IS your sketch directory, deleting the SoftwareSerial folder WILL solve your problem.

But, it's your decision as to what to do.

My sketch directory is in Document.

Thank you.

My sketch directory is in Document.

Then, the only other thing I can think of is that you are using a pre-1.0 core for the ATTiny85. You need to find a post-1.0 core to use with the post-1.0 IDE.

Okay, I think that's the problem. Have to find a newer core.

Thank you!

PaulS:

My sketch directory is in Document.

Then, the only other thing I can think of is that you are using a pre-1.0 core for the ATTiny85. You need to find a post-1.0 core to use with the post-1.0 IDE.

I searchedfor newer version : GitHub - TCWORLD/ATTinyCore: ATTiny Core for Arduino 1.0+

However, when I try to change the board to attiny 85(8MHz internal). it give me error Serial was not declared.

So how to solve that ?

Thanks !

Wait, it seems to be working !

Will update soon ! :slight_smile:

Thanks so much !

PaulS:

My sketch directory is in Document.

Then, the only other thing I can think of is that you are using a pre-1.0 core for the ATTiny85. You need to find a post-1.0 core to use with the post-1.0 IDE.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(1, 2); 
// 
int led = 4;
int state;

void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
  // initialize serial communication at 9600 bits per second:
  mySerial.begin(9600);
}

void loop() {
  if(mySerial.available() > 0){     
      state = mySerial.read();}

  if (state == '1') {
    mySerial.println(state);
      digitalWrite(led, HIGH);
    }   // turn the LED on (HIGH is the voltage level)
 
  else if (state == '2') {
    mySerial.println(state);
      digitalWrite(led, LOW);
    }    // turn the LED off by making the voltage LOW
      
  delay(100);               // wait for 100ms
  
  //For debugging purpose
  //Serial.println(state);
}

This is my current code. I want to light up and LED wirelessly through bluetooth.

I do not know why I can't get the LED to light up :frowning:

Sigh. Any ideas ?

Thanks !

Ahh, I used USBasp to upload the code to my attiny85. Then I use an android apps 'BlueTerm'' to send serial data to my attiny 85. Bad thing is that it does not display anything on the android apps.

My code :

#include <SoftwareSerial.h>

#define RxD 0
#define TxD 1
SoftwareSerial mySerial(0, 1);
// Pin 13 - LED
int led = 3;
int state;

void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(RxD, INPUT);
pinMode(TxD,OUTPUT);

// initialize serial communication at 9600 bits per second:
mySerial.begin(9600);
}

void loop() {
if(mySerial.available() > 0){
state = mySerial.read();}

if (state == '1') {
mySerial.println(state);

} // turn the LED on (HIGH is the voltage level)

else if (state == '2') {
mySerial.println(state);

} // turn the LED off by making the voltage LOW

delay(100); // wait for 100ms

//For debugging purpose
//Serial.println(state);
}

Any idea ?

Thanks !