Author Topic: USB keyboard/ controlling a computer whit a Digispark  (Read 33236 times)

potato

  • Newbie
  • *
  • Posts: 7
USB keyboard/ controlling a computer whit a Digispark
« on: August 18, 2012, 07:16:23 pm »
I would like to make a device that when plugged in the the USB port it will open up a ton of windows, just to torll some. The goal is to plug it in and it will just mess up the computer (not permanently). I don't know how or if this could be done. It could also flip the screen or something.  
« Last Edit: August 18, 2012, 07:16:23 pm by potato »

sparr

  • Jr. Member
  • **
  • Posts: 70
USB keyboard/ controlling a computer whit a Digispark
« Reply #1 on: August 20, 2012, 08:02:17 am »
Yes, the digispark can be a USB keyboard. How to accomplish your goal from a keyboard (opening windows, etc) is up to you.

potato

  • Newbie
  • *
  • Posts: 7
USB keyboard/ controlling a computer whit a Digispark
« Reply #2 on: August 20, 2012, 05:55:48 pm »
I am new to this. How that be done?

Druce

  • Newbie
  • *
  • Posts: 1
USB keyboard/ controlling a computer whit a Digispark
« Reply #3 on: August 23, 2012, 11:20:53 pm »
Is the control for keyboard output similar / the same as it is with the Leonardo?

kcbudd

  • Newbie
  • *
  • Posts: 11
USB keyboard/ controlling a computer whit a Digispark
« Reply #4 on: December 28, 2012, 02:30:27 pm »
I claim no responsibility for what happens to you if you use this:

// Evil program to toggle CAPS LOCK on and off.

#include \"DigiKeyboard.h\"

int led = 0;  // Change to pin 1 for MODEL A
int on_wait = 1000;  // How long to toggle CAPS LOCK for.
int off_wait = 5000;  // Delay between toggles.

void setup() {
  pinMode(led, OUTPUT);
  DigiKeyboard.update();
}

void loop() {
  DigiKeyboard.sendKeyStroke(57);
  digitalWrite(led, 1);
  delay(on_wait);
  DigiKeyboard.sendKeyStroke(57);
  digitalWrite(led, 0);
  delay(off_wait);
}

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
USB keyboard/ controlling a computer whit a Digispark
« Reply #5 on: December 28, 2012, 03:51:31 pm »
You\'ll probably need to call DigiKeyboard.update(); more frequently - to keep alive the usb connection, seems to vary by machine.

Also - I\'d set the off_wait using random() with at least several minutes between each trigger, you know to make it more confusing

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
USB keyboard/ controlling a computer whit a Digispark
« Reply #6 on: December 28, 2012, 04:21:02 pm »
also check out windows key then tab 3 times then down arrow one or twice then return - that would open their top programs in their start menu- though if someone did that to me I\'d likely break their digispark

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
USB keyboard/ controlling a computer whit a Digispark
« Reply #7 on: December 28, 2012, 05:15:55 pm »
On a mac, meta+alt+ctrl+8 inverts screen - If you do it again it resets back to normal, so you could type it two times in quick succession to make their screen blink invert

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
USB keyboard/ controlling a computer whit a Digispark
« Reply #8 on: December 28, 2012, 05:25:41 pm »
If you want to get up to real mischief on a mac and you have a high voltage serial programmer to remove the bootloader delay: when the digispark gets power, hold down meta+s for 5 seconds, then wait ten seconds, and you\'re logged in to a root unix terminal. Next type \"/sbin/mount -uw /\" without quotes, enter, and wait half a second - now the filesystem is writable and you can do whatever you like! It\'ll fully automatically do whatever you want to their computer next time they reboot it - leave their computer turned off and it\'ll run as soon as they try to use it!

Typing meta+s rapidly during start up isn\'t good enough - it needs to be held down, so DigiKeyboard would probably need to be modified to have that functionality?

I think digistump is going to make a high voltage programmer shield later, so this may become plausible with digispark. If you were willing to sacrifice a digispark, you could use my \'upgrade\' program to remove the bootloader, but you\'d need a fuse resetter to fix it back up afterwards, as well as a spare digispark, arduino, or avr programmer to use to reload the bootloader and disable the reset pin again if you wanted to recover the digispark, so that\'s a bit involved at the moment.

On the new solid state drive macs, all this stuff happens extremely quickly so you could be in and out before they\'ve even gotten over the shock of their screen going black and white and text zooming past at an unreadable pace. You could also type in some escape characters to reconfigure the terminal in to raw mode without echo, so they wouldn\'t be able to see the commands the digispark types in, only the results of those commands, meaning you could use \'echo\' to make it say all sorts of crazy things, or use the \'say\' command to use the computer voice to read out text.
« Last Edit: December 28, 2012, 05:28:53 pm by Bluebie »

maudette01432

  • Newbie
  • *
  • Posts: 16
USB keyboard/ controlling a computer whit a Digispark
« Reply #9 on: January 06, 2013, 05:51:35 am »
Question on the USB Keyboard driver.  Is there a way to send keyboard events vs key presses...notably KEY DOWN and KEY UP for various letters.  

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
USB keyboard/ controlling a computer whit a Digispark
« Reply #10 on: January 06, 2013, 10:22:54 am »
I\'m sure someone could add it, but it isn\'t built in already

illwill

  • Newbie
  • *
  • Posts: 8
USB keyboard/ controlling a computer whit a Digispark
« Reply #11 on: January 09, 2013, 06:59:52 pm »
I am hoping we figure out how to send whole sentences instead of single letters and able to hold shift keys etc

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
USB keyboard/ controlling a computer whit a Digispark
« Reply #12 on: January 09, 2013, 08:35:31 pm »
@illwill there is nothing to figure out, you could program that all in on the Arduino side as a function that takes a string and sends the letter commands

Or to be more efficient you could add it on the library side, the code is pretty clean and not much more complex then arduino code

illwill

  • Newbie
  • *
  • Posts: 8
USB keyboard/ controlling a computer whit a Digispark
« Reply #13 on: January 09, 2013, 09:48:37 pm »
im sure someones already done it for like the Teensy, ill have to dig in the code i guess, im just lazy
as for the missing keycodes you can pull from pg. 53 http://www.usb.org/developers/devclass_docs/Hut1_11.pdf

duckythescientist

  • Newbie
  • *
  • Posts: 27
USB keyboard/ controlling a computer whit a Digispark
« Reply #14 on: January 10, 2013, 08:29:03 am »
Look at the DigiKeyboard code and the Teensy keyboard code. It is actually quite easy to add more functionality; the code structures are pretty much the same for a lot of it.