2

I wrote simple code for my Digispark (Attiny85 with Micronucleus bootloader) in Arduino IDE:

#include <DigiUSB.h>

String inst;

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

void loop() {
  if (DigiUSB.available()) {

    char inp = DigiUSB.read();

    if (inp == '\n') { 
      DigiUSB.println(inst);
      DigiUSB.println(inst.length());
      inst = "";

    } 
    else {
      inst += inp;
      }
  }

  DigiUSB.delay(1);
}

DigiUSB works just like Serial communication in classic boards

If i send string and newline char i expect it to output this string back and print its length, but instead i receiving null string and 0 in any case

Is it problem with code or microcontroller itself?

DigiUSB monitor software


EDIT: Its seems to be digispark library problem itself:

DigiUSB.println() and DigiUSB.print() accept only char arrays

Also, there is no toCharArray() from classic arduino lib and no c_str() so i cant use atoi()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.