Skip to content

Commit 9805dc9

Browse files
committed
Playing around with the Futaba VFD
1 parent c239bee commit 9805dc9

File tree

4 files changed

+167
-0
lines changed

4 files changed

+167
-0
lines changed

vfd/DSARS0040036.pdf

216 KB
Binary file not shown.

vfd/FutabaVFD.cpp

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#include "FutabaVFD.h"
2+
3+
#include <stdio.h>
4+
#include <string.h>
5+
#include <inttypes.h>
6+
#include "Arduino.h"
7+
8+
/*
9+
10+
The protocol is a really simple asyncronous serial protocol:
11+
- Display becomes active after the strobe pin has been triggered ( active LOW )
12+
- data is then sent in 8bit packets.
13+
*/
14+
15+
FutabaVFD::FutabaVFD(uint8_t clkPin, uint8_t dataPin, uint8_t strobePin, uint8_t intensity)
16+
{
17+
_clk_pin = clkPin;
18+
_dat_pin = dataPin;
19+
_stb_pin = strobePin;
20+
_intensity = intensity;
21+
}
22+
23+
void FutabaVFD::begin(uint8_t numColumns)
24+
{
25+
_numcolumns = numColumns;
26+
pinMode(_clk_pin, OUTPUT);
27+
pinMode(_dat_pin, OUTPUT);
28+
pinMode(_stb_pin, OUTPUT);
29+
30+
digitalWrite(_clk_pin, LOW);
31+
digitalWrite(_dat_pin, LOW);
32+
digitalWrite(_stb_pin, LOW);
33+
34+
delay(500);
35+
36+
strobe();
37+
send(VFD_SETINTENSITY); send(_intensity);
38+
clear();
39+
}
40+
41+
42+
void FutabaVFD::send(uint8_t data)
43+
{
44+
for (unsigned int mask = 0x80, i=0;i<8;i++,mask >>=1)
45+
{
46+
digitalWrite(_clk_pin, HIGH);
47+
delayMicroseconds(15);
48+
digitalWrite(_dat_pin, !!(data & mask));
49+
delayMicroseconds(5);
50+
digitalWrite(_clk_pin, LOW);
51+
delayMicroseconds(15);
52+
}
53+
}
54+
55+
56+
void FutabaVFD::strobe()
57+
{
58+
digitalWrite(_clk_pin,HIGH);
59+
digitalWrite(_dat_pin,HIGH);
60+
61+
digitalWrite(_stb_pin, HIGH);
62+
delay(5);
63+
digitalWrite(_stb_pin, LOW);
64+
delay(5);
65+
}
66+
67+

vfd/FutabaVFD.h

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#ifndef FutabaVFD_h
2+
#define Futaba_h
3+
4+
#include <inttypes.h>
5+
#include "Print.h"
6+
7+
// commands
8+
#define VFD_CLEARDISPLAY 0x01
9+
#define VFD_SETCURSOR 0x02
10+
#define VFD_SETINTENSITY 0x04
11+
12+
class FutabaVFD : public Print
13+
{
14+
public:
15+
FutabaVFD(uint8_t clk, uint8_t data, uint8_t strobe, uint8_t intensity = 0x0ff);
16+
17+
// clear display, set cursor position to zero
18+
void clear() { send(VFD_CLEARDISPLAY); }
19+
void begin(uint8_t numColumns = 20);
20+
21+
// set cursor position to zero
22+
void home() { setCursor(0,0); }
23+
void setCursor(uint8_t col, uint8_t row) { send(VFD_SETCURSOR); send((row) * _numcolumns + (col+1)); }
24+
25+
virtual size_t write(uint8_t data) { send(data); return 1; }
26+
using Print::write;
27+
28+
void strobe();
29+
void send(uint8_t);
30+
private:
31+
32+
uint8_t _clk_pin; // active high.
33+
uint8_t _dat_pin; // active high.
34+
uint8_t _stb_pin; // active low. it seems to be a device reset or smth. must be triggered at
35+
// least once before displaying.
36+
37+
uint8_t _numcolumns;
38+
uint8_t _intensity;
39+
};
40+
41+
#endif

vfd/vfd.ino

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
FutabaVFD Library - Hello World
3+
4+
Tested with Futaba US202SD01A/C
5+
6+
This sketch prints "Hello World!" to the LCD
7+
and shows the time.
8+
9+
The pinout for the Futaba US202SD01A/C displays is as follows:
10+
11+
1 - +5V ( can be powered from arduino board)
12+
2 - CLOCK
13+
3 - GND
14+
4 - DATA
15+
5 - STROBE
16+
17+
The circuit:
18+
VFD +5V to 5V
19+
VFD CLOCK pin to digital pin 5
20+
VFD GND pin to ground ( GND )
21+
VFD DATA pin to digital pin 4
22+
VFD STROBE pin to digital pin 3
23+
24+
API loosly based on LiquidCrystal library (https://www.arduino.cc/en/Reference/LiquidCrystal)
25+
26+
This example code is in the public domain.
27+
28+
https://github.com/nervus/FutabaVFD
29+
*/
30+
31+
// include the library code:
32+
#include "FutabaVFD.h"
33+
34+
// initialize the library with the numbers of the interface pins
35+
// clock, data, strobe
36+
FutabaVFD vfd(6, 3, 4);
37+
38+
void setup()
39+
{
40+
Serial.begin(115200);
41+
Serial.println("Hello vfd");
42+
43+
vfd.begin(40);
44+
45+
// Print a message to the LCD.
46+
vfd.setCursor(0, 0);
47+
vfd.print("Hello, world!");
48+
delay(5000);
49+
}
50+
51+
void loop() {
52+
// set the cursor to column 0, line 1
53+
// (note: line 1 is the second row, since counting begins with 0):
54+
Serial.println("Showing time ");
55+
vfd.setCursor(0, 1);
56+
vfd.print(millis() / 1000);
57+
58+
delay(5000);
59+
}

0 commit comments

Comments
 (0)