I am currently doing a project using a bluetooth module where I try to control a LED wirelessly through a bluetooth module and attiny 85 - to save pins.
I believe the trouble is the SoftwareSerial library was written for the earlier versions of Arduino, such as the 0.22 release. In that version, the write function did not return anything (i.e. it had a void return). In the 1.0 release and beyond, write now returns the amount of bytes that were actually written (i.e. the return type is size_t).
You would presumably need to modify the .h file to change the calling signature to size_t write (...), and then change the .cpp file to return a 1 in the write functions.
I would imagine that somebody else has already done this, and you might be able to find a newer version of SoftwareSerial.
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.
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.
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.
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 ?
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.
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.
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.
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.
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.
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.
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.