Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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()

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.