Use arduino micro to write paragraphs automatically on your computer with specific speed
#include "Keyboard.h"
void setup() {
// open the serial port:
Serial.begin(9600);
// initialize control over the keyboard:
Keyboard.begin();
delay(10000);
}
void loop() {
typewriter(paragraph,95);
}
void typewriter(String text, int speedPercentage)
{
for(int i=0; i<text.length(); i++)
{
Keyboard.write(text.charAt(i));
switch(text.charAt(i))
{
case '.':
delay(random(floor(map(speedPercentage, 100, 0, 100, 1000)),floor(map(speedPercentage, 100, 0, 200, 3000))));
break;
case '?':
delay(random(floor(map(speedPercentage, 100, 0, 100, 1000)),floor(map(speedPercentage, 100, 0, 200, 3000))));
break;
case '!':
delay(random(floor(map(speedPercentage, 100, 0, 100, 1000)),floor(map(speedPercentage, 100, 0, 200, 3000))));
break;
case ';':
delay(random(floor(map(speedPercentage, 100, 0, 100, 1000)),floor(map(speedPercentage, 100, 0, 200, 3000))));
break;
default:
delay(random(floor(map(speedPercentage, 100, 0, 10, 1000)),floor(map(speedPercentage, 100, 0, 40, 4000))));
break;
}
}
}
Comments
Post a Comment