arduino - Change input to a smaller range -


first time poster here please go easy on me? :)

i'm playing around teensy 3.1 arduino compatible board, see can thing. have code found emulates keyboard , types in 0000 enter, 0001 enter, way 9999.

i want adjust code can change ranges ever like, example starting 2000-3000 or 2500-2600, etc. if tell me lines need adjusted achieve that, i'll thankful.

    #include <usb_keyboard.h> // code licensed under apache 2.0 license // http://www.apache.org/licenses/license-2.0.txt // limitation of liability. in no event , under no legal theory, // whether in tort (including negligence), contract, or otherwise, // unless required applicable law (such deliberate , grossly // negligent acts) or agreed in writing, shall contributor // liable damages, including direct, indirect, special, // incidental, or consequential damages of character arising // result of license or out of use or inability use // work (including not limited damages loss of goodwill, // work stoppage, computer failure or malfunction, or , // other commercial damages or losses), if such contributor // has been advised of possibility of such damages. // code indented people not able contact // apple support , in no way liable damage or // problems code might cause.  const int ledpin = 13; // choose pin led int counter = 0; int fakecounter = counter; char pin[] = "xxxx";  void setup() {   pinmode(ledpin, output); // declare led output   delay(10000); }  void loop() {   keyboard_modifier_keys = 0;   if (counter <= 9999) {     delay(8000);     digitalwrite(ledpin, low);     delay(5500);     digitalwrite(ledpin, high);     sprintf(pin, "%04d", fakecounter);     //sending first digit     keyboard.press(pin[0]);     delay(450);     keyboard.release(pin[0]);     delay(420);     //sending second digit     keyboard.press(pin[1]);     delay(398);     keyboard.release(pin[1]);     delay(510);     //sending third digit     keyboard.press(pin[2]);     delay(421);     keyboard.release(pin[2]);     delay(423);     //sending forth digit     keyboard.press(pin[3]);     delay(430);     keyboard.release(pin[3]);     delay(525);     //sending enter     keyboard.press(key_enter);     delay(305);     keyboard.release(key_enter);   }   //reached 4 digit pin max value   if (counter > 9999) {     (int blinkies = 0; blinkies < 8; blinkies++) {       digitalwrite(ledpin, high);       delay(20);       digitalwrite(ledpin, low);       delay(200);     }     delay(6000);   }   ++counter;   fakecounter = counter; } 

int counter = 0; beginning , if (counter <= 9999) { defines end. change 0 choice of beginning , 9999 choice of ending.


the code works because keyboard.press , keyboard.release accepts character select key press , release. uses sprintf value of counter char array pin, converting int string, using value of variable fakecounter middleman. value of counter increased , it's typed in virtual keyboard along enter key.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -