Close

Basic LED matrix control

A project log for Word watch

There's not much that's more EDC than a watch. LED matrix-based word watch, inspired by Daniel Rojas's micro word clock recently on the blog

pointyointmentPointyOintment 12/03/2014 at 04:370 Comments

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