The Digispark > Digispark Libraries
SoftSerial does not work (with clones)
(1/1)
feklee:
Disclaimer: This is with two Digispark clones (ATtiny85).
I realized that there are issues when I tried serial communication with a Teensy 3.2, as documented in the Teensy forum: Serial communication: Teensy 3.2 received junk from Digispark clone (ATtiny85)
Then I tried again with two Digispark clones, connected at pin 0 for half duplex unidirectional communication. See attached photo.
The sender sends a character x about every two seconds. The receiver does receive something, but it does not match an x.
Who is to blame? I, the hardware, SoftSerial, the Digispark design, or something else?
What follows is the code, compiled and uploaded with Digispark (16 Mhz - No USB) selected in the Arduino IDE.
sender.ino:
--- Code: ---#include <SoftSerial.h>
#include <TinyPinChange.h>
const uint8_t ledPin = 1;
const uint8_t txRxPin = 0;
SoftSerial mySerial(txRxPin, txRxPin); // RX, TX
void setup() {
mySerial.begin(4800);
mySerial.txMode();
pinMode(ledPin, OUTPUT);
}
void flashLed() {
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
}
void loop() {
mySerial.write("x");
flashLed();
delay(2000);
}
--- End code ---
receiver.ino: (play with commenting out the if clause)
--- Code: ---#include <SoftSerial.h>
#include <TinyPinChange.h>
const uint8_t ledPin = 1;
const uint8_t txRxPin = 0;
SoftSerial mySerial(txRxPin, txRxPin); // RX, TX
void setup() {
mySerial.begin(4800);
mySerial.rxMode();
pinMode(ledPin, OUTPUT);
}
void flashLed() {
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
}
void loop() {
if (mySerial.available()) {
char c = mySerial.read();
if (c == 'x')
flashLed();
}
}
--- End code ---
feklee:
--- Quote from: feklee on February 07, 2018, 08:26:35 am ---Who is to blame? I, the hardware, SoftSerial, the Digispark design, or something else?
--- End quote ---
To answer my own question:
☑ the hardware
I tried with another board as the sender, and then it worked. Also communication with the Teensy does work now.
Navigation
[0] Message Index
Go to full version