Pages: 1 [2]   Go Down
Author Topic: Attiny 85 with SoftwareSerial library  (Read 556 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 2
Posts: 336
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Sr. Member
****
Karma: 2
Posts: 336
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Thank you!
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 336
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Thanks so much !
« Last Edit: November 03, 2013, 10:54:25 am by Vincent19 » Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 336
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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 smiley-sad

Sigh. Any ideas ?

Thanks !
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 336
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: 1 [2]   Go Up
Jump to: