0

I made a simple test sketch to make my ATTiny85 emulate a Keyboard and send a sequence of keystrokes.

#include "DigiKeyboard.h"
void setup() {
  // don't need to set anything up to use DigiKeyboard
}

void loop() { DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(0); DigiKeyboard.sendKeyStroke(106); // F15 DigiKeyboard.delay(59 * 1000); }

It worked fine, but now every time I plug it to the USB port on my computer, Windows detects it as a Keyboard and starts typing what I programmed it to type.

Arduino IDE can't reprogram it. When it says "Plug in device now", I do it, but it immediately acts like a Keyboard, not like a programmable ATTiny85.

Arduino IDE

Note: Image shows the console output. Code is just a simple blinker.

Is there any way to save this board? I just want to upload another sketch to it. Maybe some way to rewrite the bootloader or to erase the flash memory entirely.

Also, please give me some advice so I can avoid being locked out again in the future. I really want to use this board as a Keyboard emulator, but I want to be able to reprogram it if necessary.

ATTiny85

  • 1
    Please don't post images of code. Just copy and post your code into the editor, and then format it as a code sample. – sempaiscuba Aug 22 '22 at 23:24
  • @sempaiscuba the code is not the important part of the image... The console output is. – Daniel Ribeiro Aug 22 '22 at 23:42
  • 1
    add the console output as text, not a picture – jsotola Aug 22 '22 at 23:52
  • use a switch or a jumper to enable the keyboard code – jsotola Aug 22 '22 at 23:53
  • You have nothing connected to the board at all except the computer? – timemage Aug 23 '22 at 00:25
  • This board is a tricky one, because the bootloader cannot be protected. -- As you describe it, you do everything correctly. After starting the upload, the board needs to be connected, so that its software starts. Commonly you disconnect the board before starting the upload. If the bootloader is present, it waits for 5 seconds for the uploader of the PC, before it launches the user application. -- Anyway, if the uploader does not connect to your board, the bootloader might be overwritten. -- Did you try to remove the device in the Hardware Manager? Windows might get into the way. – the busybee Aug 23 '22 at 06:26
  • @timemage, yes, that's correct. Nothing is connected to the board, except the computer on the USB connection. – Daniel Ribeiro Aug 23 '22 at 11:11
  • @thebusybee, Yes, I tried to remove the device in the Hardware Manager, but when I reconnect it, it shows up again. I also tried to replace the driver using Zadig (to libusb-win32) and now Windows doesn't detect it as a keyboard as before... but I still can't write a new sketch to it. – Daniel Ribeiro Aug 23 '22 at 11:17
  • Well, then I'll assume that you lost the bootloader. There are multiple resources in the web that describe how to flash the bootloader. You should prefer the instructions of the manufacturer or similar serious site. Or buy a new device. – the busybee Aug 23 '22 at 11:45
  • Yeah, I could just buy a new one, upload a new sketch and being locked outside again, the same way I am now... That's not sustainable, It should not be impossible to upload a new program multiple times. That's what this question is about: How to fix this specific board and how to prevent from being locked out again. – Daniel Ribeiro Aug 23 '22 at 16:50

1 Answers1

2

If you can't access the bootloader using USB your remaining option is ISP/ICSP (In-Circuit Serial Programming). I have that digispark board and I have never been able to program it using Arduino's IDE/USB. However, since then I always use both an USBasp programmer and the AVRDUDESS programming tool. With them you can eassily program the controller (they have never failed me). Connect the SPI, +5V, GND and RESET connectors from the ATTINY85 to the programmer, compile the code, program the binaries with AVRDUDESS and voila.

jcfgonc
  • 21
  • 4