MATRIXLEDでランダム点灯させるプログラムです!
randomSeed
という関数で乱数のパターンを設定したから使用するのがポイントですね。
#include "LedControl.h"
LedControl lc=LedControl(12,10,11,1);
long randNumber_x;
long randNumber_y;
void setup() {
lc.shutdown(0,false);
/* Set the brightness to a medium values */
lc.setIntensity(0,8);
/* and clear the display */
lc.clearDisplay(0);
Serial.begin(9600);
randomSeed(100);
}
void loop() {
randNumber_x = random(0,8);
randNumber_y = random(0,8);
Serial.println(randNumber_x);
Serial.println(randNumber_y);
delay(400);
lc.setLed(0,randNumber_x,randNumber_y,true);
}