Go Down

Topic: Attiny 85 with SoftwareSerial library (Read 757 times) previous topic - next topic

Vincent19


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

PaulS

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

Vincent19

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

Thank you!

Vincent19

#18
Nov 03, 2013, 04:52 pm Last Edit: Nov 03, 2013, 04:54 pm by Vincent19 Reason: 1

Quote
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 : https://github.com/TCWORLD/ATTinyCore

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 ! :)

Thanks so much !

Vincent19


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

Code: [Select]
#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 :(

Sigh. Any ideas ?

Thanks !

Vincent19

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

#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 !

Go Up