« DHT11 で計測の温度と湿度を TM1637 に表示する | Main | ガラ携Docomo のメールを PCで読む »

09/26/2019

4-8x8dot LED matrix を使ったテキストの scrolling 表示

筆者は最近ドライブレコーダを購入してAK12とAK13、2台のマーチに取り付けた。そこで思いついたのは、後方から迫る車に、4-8x8dot LED matrix を使って、ドライブレコーダで録画していると知らしめれば、防御運転には更に効果的ではないかと思った。
仮に後方からの運転者が、英語を理解できるとして「Drive recorder working!」と表示するとする。しかし、この表示装置では「Drive」までしか表示できないため、すべてのテキストを表示するには、テキストを scrolling しなければならない。
先日、4-8x8dot LED matrixを使って、時刻表示したときの sketchや、Github にあるテキストのスクロール表示を参考に、取り組んでみた。
Arduino NANO を使えば、物理的な回路は、結線だけで出来てしまう。

《使用部品》
1) arduino用 4-8x8dot LED matrix MAX7219
2) Arduino NANO
3) ジャンパー用配線

《接続》
Arduino NANO ---- MAX7219
5V  ---------------- VCC : 写真では「茶色」
GND --------------- GND : 写真では「赤色」
D11 --------------- DIN : 写真では「橙色」
D10 --------------- CS : 写真では「黄色」
D13 --------------- CLK : 写真では「緑色」

《参考にしたブログ》
1)  私が以前に投稿したブログ
  http://spice-cabinet.cocolog-nifty.com/blog/2019/06/post-6766a7.html


《Sketch》

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
int pinCS = 10; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
int numberOfHorizontalDisplays = 4;
int numberOfVerticalDisplays = 1;
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
String tape = "Drive-recorder working!";
int wait = 100; // In milliseconds
int spacer = 1;
int width = 5 + spacer; // The font width is 5 pixels
void setup() {
matrix.setIntensity(7); // Use a value between 0 and 15 for brightness
// Adjust to your own needs
matrix.setPosition(0, 3, 0); // The first display is at <0, 0>
matrix.setPosition(1, 2, 0); // The second display is at <1, 0>
matrix.setPosition(2, 1, 0); // The third display is at <2, 0>
matrix.setPosition(3, 0, 0); // And the last display is at <3, 0>
// ...
matrix.setRotation(0, 1); // The first display is position upside down
matrix.setRotation(1, 1); // The first display is position upside down
matrix.setRotation(2, 1); // The first display is position upside down
matrix.setRotation(3, 1); // The first display is position upside down
}
void loop() {
for ( int i = 0 ; i < width * tape.length() + matrix.width() - 1 - spacer; i++ ) {
matrix.fillScreen(LOW);
int letter = i / width;
int x = (matrix.width() - 1) - i % width;
int y = (matrix.height() - 8) / 2; // center the text vertically
while ( x + width - spacer >= 0 && letter >= 0 ) {
if ( letter < tape.length() ) {
matrix.drawChar(x, y, tape[letter], HIGH, LOW, 1);
}
letter--;
x -= width;
}
matrix.write(); // Send bitmap to display
delay(wait);

« DHT11 で計測の温度と湿度を TM1637 に表示する | Main | ガラ携Docomo のメールを PCで読む »

Arduino」カテゴリの記事

Comments

The comments to this entry are closed.

April 2024
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        

Recent Trackbacks

無料ブログはココログ