Hello,
this code below should send one stored number each 500ms. However it gives me totally strange numbers. It can be fixed by deleting "PROGMEM" word, or by replacing "random(60)" by some fixed number. I am beginner and was not able to figure out what is wrong. Thank you for any hint.
My setup is Arduino Nano ATMega328P- chinese copy, Arduino IDE 1.8.19, running on Mint
const long primeNo[60] PROGMEM = {58687, 58693, 58699, 58711, 58727, 58733, 58757, 58763, 58771, 58787,
58789, 58831, 58889, 58897, 58901, 58907, 58909, 58913, 58921, 58937,
58943, 58963, 58967, 58979, 58991, 58997, 59009, 59011, 46819, 46829,
46831, 46853, 46861, 46867, 46877, 46889, 46901, 46919, 46933, 46957,
46993, 46997, 47017, 47041, 47057, 47059, 47087, 47093, 47111, 47119,
47123, 47129, 47137, 47143, 47147, 47149, 47161, 47189, 47207, 47221};
void setup() {
Serial.begin(9600);
randomSeed(analogRead(0));
}
void loop() {
Serial.println(primeNo[random(60)]);
delay(500);
}
Here you can see typical numbers I am receiving:
0
0
9896312
-67584
0
101058054
207
207
162
101058054
101058054
3