Digispark Attiny85 devboard USB port question

Hello!

I just got myself a Attiny85 from digispark (the one with a normal usb male) and been trying to figure out the following:

What I want:
When I connect the attiny via the buildt in usb on the devboard to a computer, the buildin led (pin 1) should light up IF the attiny recieves data from the computer via the USB.

What I've tried:
My knowledgebase is limited but I viewed multiple libraries (DigiUSB, DigiCBC, SerialUSB) and tried different example codes with my own modifications. Without results.

I can upload and run simple code but Iam clueless in how I can make it stay connected to the PC.

I know that the above is not at all a good explanation but I don't know much about this stuff so if anything is unclear please just ask counter questions and I will do my best to clear it out.
image
Image is from: Useless Pin 5 in all Digispark ATtiny85 boards? [SOLVED] - #3 by pplg

Anyone? If my post is written in a bad way please tell me so I can fix it. Really need help with this one.

If I understand your question correctly and you want to use USB serial connection you will not be able to because it is not supported.

Hello and thank you for your reply!
Well, not necessarily serial. A usb have 4 physical wires (atleast in usb 2.0), 1 for 5v, 1 for GND, 1 for D+ and one for D-. I want to know if anything passes through D+ or D-, aka traffic is recieved from the source Ive plugged the USB into. And if it get's any data then I just want the built in LED on the board to light up.

Rubbish....... look here.
https://www.youtube.com/watch?v=MmDBvgrYGZs

Yes that works fine. :slight_smile: But unsure if my problem is even possible with this device :frowning:

It's not rubbish. Nowhere in the video from the link did I see work with the serial monitor.

https://digistump.com/wiki/digispark/tutorials/connecting - 'The Digispark supports all features found in the IDE with the exception of the serial monitor and the burn bootloader functionality.'

There is no hardware serial port, but you can use software serial.

http://digistump.com/board/index.php?topic=862.0

Wow... this could actually be it! I tried that library before but with 16.5 instead of 16 or 8 (as your link mentions). Will try to make that change and read from the USB pins once more!

EDIT to the below: Now it seems to work :smiley: Besides that the led wont turn off after (what i think) the data stream is cancelled)

Im new to this so Im unsure if my code is correct... Anyone care to take a look?
Right now the led (pin 1) lights up as if data is recieved (my goal)... but even if i plug it into a power outlet in the wall. So not working :frowning:

Running the Digispark on 8Mhz (based on my choice in arduino IDE)

#include <SoftwareSerial.h>

const byte rxPin = 3;
const byte txPin = 4;

// Set up a new SoftwareSerial object
SoftwareSerial mySerial (rxPin, txPin);

void setup() {                
  mySerial.begin(38400);
  pinMode(1, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  if (mySerial.available() > 0) {
        digitalWrite(1, HIGH);
        delay(2000);
    }
  else {
    digitalWrite(1, LOW);
  }
}

if there is something available and you never read it to empty the buffer, it will always be available.

#include <SoftwareSerial.h>

const byte rxPin = 3;
const byte txPin = 4;

// Set up a new SoftwareSerial object
SoftwareSerial mySerial (rxPin, txPin);

void setup() {
  mySerial.begin(38400);
  pinMode(1, OUTPUT);

  while (mySerial.available() > 0) {
    mySerial.read();  // empty buffer
  }
}

// the loop routine runs over and over again forever:
void loop() {
  if (mySerial.available() > 0) {
    digitalWrite(1, HIGH);
    while (mySerial.available() > 0) {
      mySerial.read();  // empty buffer
    }
    delay(2000);
  }
  else {
    digitalWrite(1, LOW);
  }
}

For software serial as #8 suggested, also take a look at this video.......
https://www.youtube.com/watch?v=HJ4mhXv-MXo

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.