I'm new to digispark, and I'm just playing around with the basics... and running into trouble already.
I want to make a single sketch which does something different whether or not it's plugged into a computer. How do I test whether DigiKeyboard has initialised successfully?
#include "DigiKeyboard.h"
int ledPin = 1;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(1000);
DigiKeyboard.update();
DigiKeyboard.sendKeyStroke(0);
DigiKeyboard.print("\ntest");
}
This works fine when plugged into my computer, but when plugged into a (disconnected) powered hub, or just a usb power adapter, it blinks once and stops - obviously because the DigiKeyboard. functions are failing.
Is there a way to test whether DigiKeyboard has initialised successfully and is available?
I've searched, both the forum, and google, and spent several hours reading everything I can find about DigiKeyboard without finding an answer. But hopefully it's something simple I've overlooked.