Create random character lines in Arduino

Asked

Viewed 85 times

0

Good afternoon, I wanted to make Arduino digispark type a line with 8 random characters and jump to the other line doing the same thing, only I don’t know how to control the size for this...

`#include “DigiKeyboard.h”

String aleatorio[] = {“0123456789”};
void setup() {
// don’t need to set anything up to use DigiKeyboard
}

void loop() {

DigiKeyboard.sendKeyStroke(0);
DigiKeyboard.print(aleatorio[random(0, 10)]);
DigiKeyboard.delay(1000);
}`
  • Note that the double quotes you have in the code are double quotes of word type text editor and not those used in programming. The DigiKeyboard.print what kind ? a String ? It was in this print that you wanted to send a String 8 characters long ?

  • can be a string only that at most it must have 8 characters, in this program he creates the random numbers only that does not stop to write, I would need him to write the 8 and jump to another line and write 8 so on

  • At this time I have no way to test but this can be done in several ways, one more within the world of the Aryan would be this. Naturally it is necessary to test and see if something is out

1 answer

0


I got

#include "DigiKeyboard.h" char aleatorio[] = {"abcdefghijklmnopqrstuvxz0123456789"}; // 0 a 33 char aleatorioNumeros[] = {"0123456789"}; // 0 a 9 char retirada[6]; void setup() { } void loop() { DigiKeyboard.sendKeyStroke(0); for(int i=0; i<6; i++){ retirada[i] = aleatorioNumeros[random(0,9)]; }
DigiKeyboard.println(retirada); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(500); }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.