My digispark does not respect the 5 second delay when connecting

This happened after I uploaded a sketch to it that simulates a keyboard, after that, every time I plug it into my computer, it immediately starts executing keyboard commands, making a new code upload impossible, because by default it waits for 5 seconds for any code upload request.

When connecting to the usb port, it doesn't even turn on the red led, which indicates that it is ready to receive a code. It already turns on with the yellow led, which indicates that it is in code execution mode.

I already tried to follow the troubleshooting recommendations on the digistump website, but manually I was successful.

I believe I need to rewrite its bootloader, but I've seen tutorials that only use an Arduino Uno, which I don't own. Fortunately I have an esp8266 nodemcu and I wanted to know if it is possible to rewrite my digispark bootloader through esp8266.

Comprar o NodeMCU V3 - CH340 | Componentes Eletrônicos e Arduino (curtocircuito.com.br) - Version of my Esp8266

Placa de Desenvolvimento ATTINY85 Digispark - FilipeFlop - My digispark

Help us help you.

Sorry about that, I'm new here. Below is the keyboard simulator code that I recorded for the last time in my digispark ->

//This DigiKeyboard Script downloads and sets a wallpaper through the Windows PowerShell. It has been tested successfully
//on Windows 10 and should probably work with Windows 7/8/8.1 etc.

#include "DigiKeyboard.h"
void setup() {
  //empty
}
void loop() {
  DigiKeyboard.sendKeyStroke(0);
  DigiKeyboard.sendKeyStroke(KEY_D, MOD_GUI_LEFT);
  DigiKeyboard.delay(500);
  DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
  DigiKeyboard.delay(500);
  DigiKeyboard.print("cmd");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.delay(1500);
  DigiKeyboard.print("cd C:/Users/Joilma/Downloads");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.print("type nul > “script_do_excel.txt”");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.delay(500);
  DigiKeyboard.print("script_do_excel.txt");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.delay(1500);
  DigiKeyboard.print("//codigo a ser escrito no notepad");
  DigiKeyboard.sendKeyStroke(KEY_S , MOD_CONTROL_LEFT | MOD_SHIFT_LEFT);
  DigiKeyboard.delay(1000);
  DigiKeyboard.print("script_do_excel.vbs");


  
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.delay(500);
  

  for(;;){ /*empty*/ }
}

Message of console Arduino IDE:

O sketch usa 3046 bytes (50%) de espaço de armazenamento para programas. O máximo são 6012 bytes.
Variáveis globais usam 232 bytes de memória dinâmica.
Running Digispark Uploader...
Plug in device now... (will timeout in 60 seconds)

But when connecting the digispark the code loading does not start and reaches the timeout of 60 s

The code you have posted has an empty setup()
and this code has absolutely no wait. The code immidiately and unconditional starts sending keystrokes.

For future use:
add a always active delay(5000) in setup and
add some lines of code that will start sending keystrokes only in case a certain IO-pin that is configured INPUT_PULLUP receives a LOW signal through externally connecting the IO-pin to ground.

Thanks man, I know that the code is empty, but that's not what matters to me, because the 5s delay, I believe it's a digispark feature, not being configurable in the setup().

When I manage to fix it, I will follow your recommendations

Another sign that something is not right: when you put the digispark on the usb, it must stay on for 5s with the red led on, indicating that it is ready to receive a code. This does not happen on my digispark, as it simply turns on with the green led on, which indicates that the code recorded in it is running.

1 Like

Thanks guy, I've seen this video, but I don't have an arduino uno. I have an esp8266 but I don't know if it's possible with it.