10. Pahatahtlik klaviatuur

#include "DigiKeyboard.h"
#define KEY_UP_ARROW   0x52
#define KEY_DOWN_ARROW   0x51
#define KEY_LEFT_ARROW   0x50
#define KEY_RIGHT_ARROW   0x4F
#define KEY_PRINT_SCR   70
#define KEY_TAB   43

int nupp = 2;
int punaneLed = 5;
int rohelineLed = 0;
int sinineLed = 1;

int varvid_s = 0;
int varvid_i = 0;

void setup() {
  pinMode(nupp, INPUT);
  pinMode(punaneLed, OUTPUT);
  pinMode(sinineLed, OUTPUT);
  pinMode(rohelineLed, OUTPUT);

  randomSeed(analogRead(A1));

  DigiKeyboard.update();
  DigiKeyboard.delay(200);
  DigiKeyboard.sendKeyStroke(0); 
  DigiKeyboard.delay(200);
  DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
  DigiKeyboard.delay(200);
  DigiKeyboard.print("msg ");//See käsk ei tööta Home edition Windowsil
  DigiKeyboard.sendKeyStroke(85);
  DigiKeyboard.println("Vajuta nuppu USB seadmel!");

  DigiKeyboard.update();
  DigiKeyboard.delay(200);
  DigiKeyboard.sendKeyStroke(0); 
  DigiKeyboard.delay(200);
  DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
  DigiKeyboard.delay(200);
  DigiKeyboard.print("chrome hackest.org");
  DigiKeyboard.sendKeyStroke(84); 
  DigiKeyboard.print("usb");
  DigiKeyboard.sendKeyStroke(84);
  DigiKeyboard.println("vajuta");
  
}


void loop() {

  DigiKeyboard.update();

  if (digitalRead(nupp)==HIGH) {
    teePaha();
    delay(3000);
  }

  muudaVarve();
  
  DigiKeyboard.delay(10);
}


void teePaha() {

  DigiKeyboard.sendKeyStroke(0); 
  DigiKeyboard.delay(200);
  switch (random(15)) {
    case 0: 
      DigiKeyboard.sendKeyStroke(KEY_M, MOD_GUI_LEFT);
      break;

    case 1:
      DigiKeyboard.sendKeyStroke(KEY_L, MOD_GUI_LEFT);
      break;

    case 2: 
      DigiKeyboard.sendKeyStroke(KEY_DOWN_ARROW, MOD_GUI_LEFT);
      break;

    case 3: 
      DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
      DigiKeyboard.delay(200);
      DigiKeyboard.print("msg ");
      DigiKeyboard.sendKeyStroke(85);
      DigiKeyboard.println(" Tere, sinu arvutis on viirus.     Haha, nali :D");
      break;

    case 4:
      DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
      DigiKeyboard.delay(200);
      DigiKeyboard.print("cmd");
      delay(200);
      DigiKeyboard.sendKeyStroke(KEY_ENTER);
      DigiKeyboard.delay(200);
      DigiKeyboard.print("shutdown ");
      DigiKeyboard.sendKeyStroke(86);
      DigiKeyboard.println("L");

    case 5: 
      DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
      DigiKeyboard.delay(200);
      DigiKeyboard.println("cmd");
      DigiKeyboard.delay(200);
      DigiKeyboard.println("tree");
      DigiKeyboard.sendKeyStroke(KEY_F11);
      break;

    case 6: 
      DigiKeyboard.sendKeyStroke(KEY_PRINT_SCR, MOD_SHIFT_LEFT + MOD_ALT_LEFT);
      DigiKeyboard.delay(500);
      DigiKeyboard.sendKeyStroke(KEY_ENTER);
      break;

    case 7: 
      DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
      DigiKeyboard.delay(200);
      DigiKeyboard.print("chrome hackest.org");
      DigiKeyboard.sendKeyStroke(84); 
      DigiKeyboard.print("usb");
      DigiKeyboard.sendKeyStroke(84);
      DigiKeyboard.println("funktsioonide-spikker");
      break;

    case 8: 
      DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
      DigiKeyboard.delay(200);
      DigiKeyboard.println("chrome");
      DigiKeyboard.delay(1000);
      DigiKeyboard.println("programmeerimine.ut.ee");
      break;

    case 9: 
      DigiKeyboard.sendKeyStroke(KEY_TAB, MOD_ALT_LEFT);
      DigiKeyboard.delay(1000);
      DigiKeyboard.sendKeyStroke(KEY_TAB, MOD_ALT_LEFT);
      DigiKeyboard.sendKeyStroke(KEY_TAB, MOD_ALT_LEFT);
      break;

    case 10: 
      DigiKeyboard.sendKeyStroke(KEY_D, MOD_CONTROL_LEFT + MOD_GUI_LEFT);
     break;

    case 11:
      DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
      DigiKeyboard.delay(200);
      DigiKeyboard.println("cmd");
      DigiKeyboard.delay(200);
      DigiKeyboard.println("title See on pahalase nimeline kasurida!");
      break;

    case 12: 
      DigiKeyboard.sendKeyStroke(KEY_M, MOD_GUI_LEFT);
      DigiKeyboard.delay(300);
      DigiKeyboard.sendKeyStroke(KEY_F10, MOD_SHIFT_LEFT);
      DigiKeyboard.delay(300);
      DigiKeyboard.sendKeyStroke(KEY_DOWN_ARROW);
      DigiKeyboard.delay(200); 
      DigiKeyboard.sendKeyStroke(KEY_RIGHT_ARROW);
      DigiKeyboard.delay(200); 
      DigiKeyboard.sendKeyStroke(KEY_UP_ARROW);
      DigiKeyboard.delay(200); 
      DigiKeyboard.sendKeyStroke(KEY_ENTER);
      delay(200); 
     break;


     case 13:   
      DigiKeyboard.sendKeyStroke(0); 
      DigiKeyboard.delay(50);
      DigiKeyboard.sendKeyStroke(KEY_X, MOD_GUI_LEFT);
      DigiKeyboard.delay(200);
      DigiKeyboard.print("A");
      DigiKeyboard.delay(2000);
      DigiKeyboard.sendKeyStroke(KEY_LEFT_ARROW);
      DigiKeyboard.delay(200); 
      DigiKeyboard.sendKeyStroke(KEY_ENTER);
      DigiKeyboard.delay(1000);
      //saadame käsu "dism /online /Enable-Feature /FeatureName:TelnetClient"
      DigiKeyboard.print("dism ");
      DigiKeyboard.sendKeyStroke(84); 
      DigiKeyboard.print("online ");
      DigiKeyboard.sendKeyStroke(84); 
      DigiKeyboard.print("Enable");
      DigiKeyboard.sendKeyStroke(86); 
      DigiKeyboard.print("Feature ");
      DigiKeyboard.sendKeyStroke(84); 
      DigiKeyboard.print("FeatureName");
      //Send Unicode character U+58 meaning ":" for that we hold down ALT key and send from numpad 5 and 8 numbers. Otherwise estonian vs english keys wont match.
      DigiKeyboard.sendKeyPress(93,MOD_ALT_LEFT);
      DigiKeyboard.sendKeyPress(96,MOD_ALT_LEFT);
      DigiKeyboard.sendKeyPress(0,0);   
      DigiKeyboard.delay(100);      
      DigiKeyboard.println("TelnetClient");
      DigiKeyboard.delay(5000);
      DigiKeyboard.print("n");
      DigiKeyboard.delay(500);  
      DigiKeyboard.println("telnet towel.blinkenlights.nl");

    default:
      break;  
  }
}

void muudaVarve() {
  varvid_i++;
  if (varvid_i==256) {
    varvid_i = 0;
    varvid_s++;
    if (varvid_s==3) {
      varvid_s = 0;
    }
  }

  if (varvid_s==0) {
    if (varvid_i<127) {
      digitalWrite(punaneLed, LOW);
    }
    else {
      digitalWrite(punaneLed, HIGH);
    }
    analogWrite(rohelineLed, 255-varvid_i);
  }
  else if (varvid_s==1) {
    analogWrite(rohelineLed, varvid_i);
    analogWrite(sinineLed, 255-varvid_i);
  }
  else {
    analogWrite(sinineLed, varvid_i);
    if (varvid_i<127) {
      digitalWrite(punaneLed, HIGH);
    }
    else {
      digitalWrite(punaneLed, LOW);
    }
  }
}

Arduinosid ja elektroonikakomponente saab:
https://www.ittgroup.ee
https://www.oomipood.ee
https://www.aliexpress.com/

Vaata ka:
Funktsioonide spikker

Lisa kommentaar

Sinu e-postiaadressi ei avaldata. Nõutavad väljad on tähistatud *-ga