help with random (new to programing)

so I’m almost completely new to programing

so I desided to teach my self with a peggy 25x25 led board

I studied the examples for peggy and the arduino reference and examples but for my first program I wanted to make a random Led on the board light up one at a time

OK so if I want to create a random value that changes each time the frame is displayed what do I do?

is this the most efficient way?

// random dot.

#include <Peggy2.h>

Peggy2 frame1;// Make a frame buffer object, called frame1

float r; //first random number
float r2; //second random number
void setup()

frame1.HardwareInit(); // Call this once to init the hardware.
// (Only needed once, even if you’ve got lots of frames.)

} // End void setup()

void loop() // run over and over again

r = random(0, 24); // value is between 0, 24 the grid size on the LED board.

r2 = random(0, 24);
frame1.SetPoint(r2, r); // radom led coordinates
frame1.RefreshAll(500); //Draw frame buffer one time
if (r = r) // if random number = itself
frame1.Clear(); //then refresh the image


feel free to tare me apart I really am only just beginning to understand this and I’m no good at maths ::slight_smile:

Not sure why you're using floats.

oh should it be integer?

Yes, specifically, a long, as per the reference.