Modifying the Arduino example I linked to earlier, I made a basic sketch that takes X and Y positions via serial and illuminates the corresponding LED.
Here's the code I added/changed:
void loop() {
// read input:
while (Serial.available() > 0) {
readSerial();
}
// draw the screen:
refreshScreen();
}
void readSerial() {
// turn off the last position:
pixels[x][y] = HIGH;
// get value from serial:
x = Serial.parseInt();
y = Serial.parseInt();
if (Serial.read() == '/n') {
x = constrain(x, 0, 7);
y = constrain(y, 0, 7);
}
// set new pixel position on:
pixels[x][y] = LOW;
}
Now I can just type two digits from 0 to 7, separated by a non-digit (e.g. a space) in the serial terminal, and the corresponding LED on the matrix will light up.
Next I will try to get it to display predefined raster graphics. This will be the basis of the word clock functionality.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.