Advertisement
grinningveil72

arduinoPythonFromUsb

May 26th, 2016
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. // CREATED DEVELOPED TESTED AND EVERYTHING ELSE BY GRINNINGVEIL72
  2.  
  3. // Make the circuit on an Arduino Micro or Leonardo
  4. // 5V ---- Switch ---- ------Resistor-------GND
  5. // |
  6. // Pin 2
  7.  
  8. int stopper; //Make a variable that we will use later
  9. String file = ("lol"); //Name of the Python File
  10. String usb = ("USB"); // Name of your USB drive
  11. void setup() {
  12. Keyboard.begin(); //begin the keyboard reader
  13. pinMode(2, INPUT); // Make our switch an input
  14. }
  15. void loop() {
  16. stopper = digitalRead(2); //Our variable is set to the input from our switch
  17. if (stopper == HIGH){ // If we press the switch...
  18. delay(250);
  19. Keyboard.press(KEY_LEFT_GUI);
  20. Keyboard.press(0x20); //Command + Spacebar to open spotlight
  21. Keyboard.releaseAll();
  22. delay(250);
  23. Keyboard.print("Terminal"); //Type Terminal
  24. delay(200);
  25. Keyboard.press(KEY_RETURN); // Press Enter to open Terminal
  26. Keyboard.releaseAll();
  27. delay(250);
  28. Keyboard.press(KEY_TAB);
  29. Keyboard.releaseAll();
  30. Keyboard.press(KEY_RETURN); //Tab and return just in case it asks to open an old terminal session
  31. Keyboard.releaseAll();
  32. delay(3000);
  33. Keyboard.print("cp /Volumes/");
  34. Keyboard.print(usb);
  35. Keyboard.print("/");
  36. Keyboard.print(file);
  37. Keyboard.print(".py Desktop/"); //Copy the python file from the usb to Desktop
  38. Keyboard.press(KEY_RETURN);
  39. Keyboard.releaseAll();
  40. delay(500);
  41. Keyboard.print("cd Desktop"); //Go to the Desktop again where the python file is saved
  42. Keyboard.press(KEY_RETURN);
  43. Keyboard.releaseAll();
  44. Keyboard.print("python ");
  45. Keyboard.print(file);
  46. Keyboard.print(".py && rm ");
  47. Keyboard.print(file);
  48. Keyboard.print(".py && cd .."); //run and then delete the python file then move up a directory
  49. Keyboard.press(KEY_RETURN);
  50. Keyboard.releaseAll();
  51. delay(3000);
  52.  
  53. Keyboard.press(KEY_LEFT_GUI);
  54. Keyboard.press(KEY_LEFT_ALT); //Command Alt Escape to open up force quit menu
  55. Keyboard.press(KEY_ESC);
  56. Keyboard.releaseAll();
  57. delay(100);
  58. Keyboard.press('T');
  59. Keyboard.release('T'); //T for terminal
  60. delay(100);
  61. Keyboard.press(0xB0);
  62. Keyboard.releaseAll();
  63. delay(150);
  64. Keyboard.press(KEY_TAB); //Tab and return to close terminal
  65. Keyboard.releaseAll();
  66. Keyboard.press(KEY_RETURN);
  67. Keyboard.releaseAll();
  68. Keyboard.press(KEY_ESC); // Close the force quit menu
  69. Keyboard.releaseAll();
  70.  
  71. delay(5000); // Five second delay to give you time to unplug before the script starts again
  72. }
  73. else{
  74. delay(1); //If we don't press the switch then wait until we do
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement