Hello All, I am looking to create/obtain a random alphanumeric generator for arduino. I searched the forums and online for a solution that works in the arduino environment but came up short, so I decided to write my own. Below is my code. If you know of another random alphanumeric generator that works in the arduino space can you please just provide it? It is hard to explain exactly how my code acts. It is interesting to see how it works, as it is anti intuitive of what I'd/you'd expect. The size of the random string will be between 0 and 16000 as I will be sending over packets up to 16M and want to test it first with random bit to check for bit errors. I believe the reason I seeing what I am seeing is because of the max memory on the arduino. Please take a look and let me know what you think. Thank you.
int numBytes = 0;
int i = 0;
int j = 0;
String letters[40] = {"a", "b", "c", "d", "e", "f","g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"};
String randString = "";
void setup() {
Serial.begin(230400);
}
void loop() {
if(Serial.available())
{
numBytes = Serial.parseInt();
for(i = 0; i<numBytes; i++)
{
randString = randString + letters[random(0, 40)];
Serial.println(randString);
}
Serial.println("Here is your random string: ");
Serial.println(randString);
Serial.print("I received: ");
Serial.println(numBytes);
delay(1000);
}
}