computer-b-gone_teensy
Table des matières
Computer-b-gone Teensy
Matériel
Basé sur une Teensy 2 http://snootlab.com/417-teensy-20-usb-fr.html
Installation Logiciels
- Installer IDE Arduino 1.8.1 https://www.arduino.cc/en/Main/Software (paquet debian à la version 2 ?!)
- Il faut installer des morceaux pour que cette teensy 2 cause avec l'IDE Arduino
- suivre tuto là https://www.pjrc.com/teensy/teensyduino.html
- les règles udev https://www.pjrc.com/teensy/49-teensy.rules
Copier les règles UDEV
sudo cp 49-teensy.rules /etc/udev/rules.d/
ça donne en débranchant, rebranchant :
Mar 1 01:24:31 db kernel: [19874.712077] usb 4-1.4: new full-speed USB device number 5 using ehci-pci Mar 1 01:24:31 db kernel: [19874.822476] usb 4-1.4: New USB device found, idVendor=16c0, idProduct=0483 Mar 1 01:24:31 db kernel: [19874.822483] usb 4-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 Mar 1 01:24:31 db kernel: [19874.822487] usb 4-1.4: Product: USB Serial Mar 1 01:24:31 db kernel: [19874.822490] usb 4-1.4: Manufacturer: Teensyduino Mar 1 01:24:31 db kernel: [19874.822493] usb 4-1.4: SerialNumber: 12345 Mar 1 01:24:31 db kernel: [19874.823019] cdc_acm 4-1.4:1.0: ttyACM0: USB ACM device
soit installer teensy et teensyduino.32bit ou 64 bit https://www.pjrc.com/teensy/td_download.html avec l'installeur, ça donne au final (indiquer le répertoire où est décompressé Arduino IDE 1.8.1) :
- Dans l'IDE Arduino doit apparaitre :
board Teensy 2
et
USB Type : "Keyboard, mouse and joystick"
Programme pour déclenchement événement clavier
- Voir http://www.instructables.com/id/PC-B-Gone-V1/?ALLSTEPS pour code initial
- Les codes du clavier https://www.pjrc.com/teensy/usb_keyboard.html
- faire bouger la souris https://www.pjrc.com/teensy/usb_mouse.html
Les raccourcis mac os
KEY_LEFT_GUI // pour la touche command ou pomme
// Code writen by Matthew Varian www.3too1.com // modified by b01 // Free for distrubution and use int a=0; //define analog input pin int b=-9 ; //defines photocell trigger value void setup() { pinMode(a, INPUT); //set analog pin as input } void loop() { if(analogRead(a)>b) //if photocell is over trigger value { //send alt-f4 command // Keyboard.set_modifier(MODIFIERKEY_ALT); // Keyboard.send_now(); // Keyboard.set_key1(KEY_F4); // Keyboard.send_now(); Keyboard.set_modifier(MODIFIERKEY_CTRL); Keyboard.send_now(); Keyboard.set_modifier(MODIFIERKEY_ALT); Keyboard.send_now(); Keyboard.set_key1(KEY_DELETE); Keyboard.send_now(); Keyboard.set_modifier(0); Keyboard.set_key1(0); Keyboard.send_now(); //wait 1sec delay(1000); } }
Programme pour pilotage Souris
/* Simple USB Mouse Example Teensy becomes a USB mouse and moves the cursor in a triangle You must select Mouse from the "Tools > USB Type" menu This example code is in the public domain. */ // Mouse.click(MOUSE_LEFT); long randX; long randY; long randD; float inc = 0; //we use this to increment our angle float xPos; float yPos; float rad = 0; // the radius of our circle (it will be increasing) float decalx; float decaly; int i; void setup() { Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(5, 5); } void loop() { // Barre de navig Bas //Mouse.move(0, 0); -127 127 bas à gauche //Mouse.move(5, -5); //delay(250); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, 127); Mouse.move(-127, -5); for (i=0; i<400; i++) { decalx = 5; Mouse.move(decalx, 0); Mouse.click(MOUSE_LEFT); delay(5); } // Triangle for (i=0; i<100; i++) { Mouse.move(2, -1); Mouse.click(MOUSE_LEFT); delay(5); } for (i=0; i<100; i++) { Mouse.move(2, 2); Mouse.click(MOUSE_LEFT); delay(5); } for (i=0; i<100; i++) { Mouse.move(-4, -1); Mouse.click(MOUSE_LEFT); delay(5); } // Random for (i=0; i<100; i++) { randX = random(-100, 100); randY = random(-100, 100); randD = random(5, 100); Mouse.move(randX, randY); Mouse.click(MOUSE_LEFT); delay(randD); } // Ellipse generator for (i=0; i<400; i++) { xPos = cos(radians(inc)) * rad; // so now we get results between -radius and radius yPos = sin(radians(inc)) * rad; Serial.println('x ', xPos); Serial.println('y ', yPos); Mouse.move(xPos, yPos); Mouse.click(MOUSE_LEFT); //we increase both the radius and the angle //note how the angles used to draw remain the same all the time even though the radius is changing //play around with this values to alter the shape of the spiral inc += 100; rad += 1; delay(25); } // Final shutdown for (i=0; i<400; i++) { Keyboard.set_modifier(MODIFIERKEY_ALT); Keyboard.send_now(); Keyboard.set_key1(KEY_F4); Keyboard.send_now(); //Keyboard.set_modifier(MODIFIERKEY_CTRL); //Keyboard.send_now(); //Keyboard.set_modifier(MODIFIERKEY_ALT); //Keyboard.send_now(); //Keyboard.set_key1(KEY_DELETE); //Keyboard.send_now(); Keyboard.set_modifier(0); Keyboard.set_key1(0); Keyboard.send_now(); //wait 1sec delay(1000); } }
Pour récupérer le controle
- brancher- débrancher le teensy
- fermer le logiciel annexe de gestion du teensy
- rebrancher le teensy
- appuyer sur le bouton de reboot
computer-b-gone_teensy.txt · Dernière modification : 2022/02/23 16:06 de Benjamin Labomedia