A Slow Display... E-Paper + Arduino
If you are wondering, E-Ink is a brand of E-Paper, and this display is not of that brand so we will be calling it E-Paper.
E-paper has some properties that make it unlike almost any other display. Unlike a typical LCD screen, E-paper only needs power when it is changing what is being displayed. Think of it as an electrical etch-a-sketch - The image is there until you change it.
The E-paper actually does this by drawing the image by flipping over tiny balls in the display that are black on one side, and white on the other. When an electrical charge is applied to portions of the display it forces the balls in that area to all flip to one side, changing the color of that part of the display. Once these balls have been set into place, they stay there until a new instruction takes place.
E-paper also is not backlit like many LCDs and is more like actual paper where reading it is dependent on available light where you are. And, many people report E-Paper as being easier on the eyes and more like reading actual paper than a screen.
This particular display is a 20 character, 2 line, 16-segment display. So you wont be able to display graphics on it, and the type size is set as well. But... it is still very cool.
Hooking It Up
I wouldn't try hooking up this display without the breakout board, so im not going to cover that at all (the break outboard bumps the 3.3 or 5[v] source to the 35V needed for the display) and there are like 400 connections on the 2 ribbon cables. Also, even with the breakout board it can be a little tricky.
The ribbon cables of the display need to slide into the connectors of the breakout board, and I have read some people having issue with this. To do this you need to slide out the sides of the connector, then slide the ribbon cable into it, and slide the sides back in, locking it into place.
You also need to make sure you are plugging the right cable into the right connector. - Look at the illustration. In the top left of the back of the display are some square / line shapes. This side needs to plug into "input 2" of the breakout-board. Im not 100% that it MUST be orientated this way, but this is how I did it, and how it is shown on SparkFun, and it worked for us. It is possible that it would just be upside-down if reversed.
Now just hook everything up as shown in the illustration.
Code
This code is based on the code example on SparkFun's site written by Jim Lindblom. With his permission, we started a library for this display that makes it very easy to write anything to the display. It has some bugs, but works quite well.
All you need to do after the library is initiated, is this:
To display a number up to 2147483647
epaper.writeNumberTop(2147483647);
epaper.writeNumberBottom(2147483647);
epaper.writeDisplay();
Or for text
epaper.writeTop(" bildr ");
epaper.writeBottom(" example ");
epaper.writeDisplay();
To make this code work, before you load the code, or even open the Arduino program, we need to place both the “ePaper” folder into your Arduino Library. If you don’t know where that is by default, Look to the right.
If you click the download button to the right of “Arduino” you can download the whole thing as a zip, so you dont need to copy all the files.
Default Library Folder Location
On your Mac:: In (home directory)/Documents/Arduino/libraries
On your PC:: My Documents -> Arduino -> libraries
On your Linux box:: (home directory)/sketchbook/libraries
Help expand the library
We would love help expanding the library if you are interested. We would like to add to support for other characters, capital and non capitol letters, left and right justify etc. The screen may also support black on white as well as black on white (not 100% sure). If you are interested in helping, let us know in the forum.
License.txt
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Copyright (c) 2010 bildr community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
README.md
E-Paper Display
Arduino code for sparkfun e-ink display https://www.sparkfun.com/products/retired/10150
For complete hookup and tutorial see: http://adam-meyer.com/arduino/e-paper
The code is provided under the MIT license please use, edit, change, and share.
Before loading the ePaper_Example.pde code, or even opening the arduino software, place the ePaper folder in your arduino library.
ARDUINO LIBRARY LOCATION
- On your Mac:: In (home directory)/Documents/Arduino/libraries
- On your PC:: My Documents -> Arduino -> libraries
- On your Linux box: (home directory)/sketchbook/libraries
For all my arduino articles: http://adam-meyer.com/arduino/
ePaper.cpp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
// Include the standard types
#include <Arduino.h>
#include <ePaper.h>
#define BLACK_BG 1
#define WHITE_BG 0
unsigned int chars[95] =
{
// abcdefgh ijklmnop
(B00000000 << 8) + B00000000, // (space)
(B00000001 << 8) + B00000001, // !
(B00000001 << 8) + B00010000, // "
(B10111011 << 8) + B11011101, // #
(B10011011 << 8) + B11011001, // $
(B01011011 << 8) + B11011010, // %
(B00010101 << 8) + B11011101, // &
(B00000001 << 8) + B00000000, // `
(B10000011 << 8) + B10000000, // (
(B00000001 << 8) + B11000001, // )
(B01010101 << 8) + B10101010, // *
(B00010001 << 8) + B10001000, // +
(B00000000 << 8) + B00000010, // ,
(B00010000 << 8) + B00001000, // -
(B00000000 << 8) + B00000001, // .
(B01000000 << 8) + B00000010, // /
// abcdefgh ijklmnop
(B10101010 << 8) + B01010101, // 0
(B01101000 << 8) + B00000000, // 1
(B10110010 << 8) + B01001101, // 2
(B10111010 << 8) + B01000001, // 3
(B00111000 << 8) + B00011000, // 4
(B10000110 << 8) + B01011001, // 5
(B10011010 << 8) + B01011101, // 6
(B11000000 << 8) + B01000010, // 7
(B10111010 << 8) + B01011101, // 8
(B10111010 << 8) + B01011001, // 9
(B00000000 << 8) + B01001000, // :
(B00000000 << 8) + B01001010, // ;
(B01000100 << 8) + B00000000, // <
(B00010010 << 8) + B00001001, // =
(B00000000 << 8) + B00100010, // >
(B10110000 << 8) + B11000000, // ?
(B10111010 << 8) + B11010101, // @
// abcdefgh ijklmnop
(B10111000 << 8) + B01011100, // A
(B10111011 << 8) + B11000001, // B
(B10000010 << 8) + B01010101, // C
(B10101011 << 8) + B11000001, // D
(B10000010 << 8) + B01011101, // E
(B10000000 << 8) + B01011100, // F
(B10011010 << 8) + B01010101, // G
(B00111000 << 8) + B00011100, // H
(B10000011 << 8) + B11000001, // I
(B00101010 << 8) + B00000101, // J
(B01000100 << 8) + B00011100, // K
(B00000010 << 8) + B00010101, // L
(B01101000 << 8) + B00110100, // M
(B00101100 << 8) + B00110100, // N
(B10101010 << 8) + B01010101, // O
(B10110000 << 8) + B01011100, // P
(B10101110 << 8) + B01010101, // Q
(B10110100 << 8) + B01011100, // R
(B10011010 << 8) + B01011001, // S
(B10000001 << 8) + B11000000, // T
(B00101010 << 8) + B00010101, // U
(B01000000 << 8) + B00010110, // V
(B00101100 << 8) + B00010110, // W
(B01000100 << 8) + B00100010, // X
(B01000000 << 8) + B10100000, // Y
(B11000010 << 8) + B01000011, // Z
(B10000010 << 8) + B01010101, // [
(B00000100 << 8) + B00100000, //
(B10101010 << 8) + B01000001, // ]
(B00000100 << 8) + B00000010, // ^
(B00000010 << 8) + B00000001, // _
(B00000001 << 8) + B00000000, // `
// abcdefgh ijklmnop
(B00000010 << 8) + B10001101, // a
(B00000000 << 8) + B10011101, // b
(B00000000 << 8) + B00001101, // c
(B00000001 << 8) + B10001101, // d
(B00000000 << 8) + B00001111, // e
(B10010001 << 8) + B10001000, // f
(B00000001 << 8) + B11011001, // g
(B00000000 << 8) + B10011100, // h
(B10000000 << 8) + B10000000, // i
(B00000001 << 8) + B10000001, // j
(B00010101 << 8) + B10000000, // k
(B00000001 << 8) + B10000000, // l
(B00011000 << 8) + B10001100, // m
(B00011000 << 8) + B10001000, // n
(B00000000 << 8) + B10001101, // o
(B00000001 << 8) + B01011100, // p
(B00000011 << 8) + B11011000, // q
(B00010000 << 8) + B10000000, // r
(B00010110 << 8) + B00000000, // s
(B00010001 << 8) + B10001000, // t
(B00000010 << 8) + B10000101, // u
(B00000000 << 8) + B00000110, // v
(B00001010 << 8) + B10000101, // w
(B01000100 << 8) + B00100010, // x
(B00000001 << 8) + B10011001, // y
(B00000000 << 8) + B00001011, // z
(B00000000 << 8) + B00000000, // {
(B00000000 << 8) + B00000000, // |
(B00000000 << 8) + B00000000, // }
(B00000000 << 8) + B00000000 // ~*/
// abcdefgh ijklmnop
};
char topData[160];
char bottomData[160];
// Constructor
ePaper::ePaper(int EIO, int XCK, int LATCH, int SLPB, int DI0)
{
_EIO = EIO;
_XCK = XCK;
_LATCH = LATCH;
_SLPB = SLPB;
_DI0 = DI0;
pinMode(_EIO, OUTPUT);
pinMode(_XCK, OUTPUT);
pinMode(_LATCH, OUTPUT);
pinMode(_SLPB, OUTPUT);
pinMode(_DI0, OUTPUT);
// Initial Pin Configurations -----------------------
digitalWrite(_SLPB, HIGH); // Sleep high turns the display on
digitalWrite(_DI0, HIGH); // Initialize data high
digitalWrite(_XCK, LOW);
digitalWrite(_EIO, HIGH);
digitalWrite(_LATCH, LOW);
}
void ePaper::flipData(char * characterData)
{
char a;
for (int i=0; i<80; i++)
{
a = characterData[i];
characterData[i] = characterData[159-i];
characterData[159-i] = a;
}
}
void ePaper::print(char * displayTop, char * displayBottom, int bw, int com)
{
digitalWrite(_EIO, LOW);
if (bw)
digitalWrite(_DI0, HIGH);
else
digitalWrite(_DI0, LOW);
delayMicroseconds(1);
clock(); // Y0
digitalWrite(_EIO, HIGH);
for (int i = 0; i<160; i++)
{
if (bw)
{
if (displayBottom[i])
digitalWrite(_DI0, LOW);
else
digitalWrite(_DI0, HIGH);
delayMicroseconds(1);
clock();
}
else
{
if (displayBottom[i])
digitalWrite(_DI0, HIGH);
else
digitalWrite(_DI0, LOW);
delayMicroseconds(1);
clock();
}
}
if (com)
digitalWrite(_DI0, HIGH);
else
digitalWrite(_DI0, LOW);
clock(); // Y161
//--- 2nd display ---
if (bw)
digitalWrite(_DI0, HIGH);
else
digitalWrite(_DI0, LOW);
clock(); // Y0
for (int i = 0; i<160; i++)
{
if (bw)
{
if (displayTop[i])
digitalWrite(_DI0, LOW);
else
digitalWrite(_DI0, HIGH);
delayMicroseconds(1);
clock();
}
else
{
if (displayTop[i])
digitalWrite(_DI0, HIGH);
else
digitalWrite(_DI0, LOW);
delayMicroseconds(1);
clock();
}
}
if (com)
digitalWrite(_DI0, HIGH);
else
digitalWrite(_DI0, LOW);
delayMicroseconds(1);
clock(); // Y161
latch();
}
void ePaper::clock()
{
digitalWrite(_XCK, HIGH);
delayMicroseconds(1);
digitalWrite(_XCK, LOW);
delayMicroseconds(1);
}
void ePaper::latch()
{
digitalWrite(_LATCH, HIGH);
delayMicroseconds(5);
digitalWrite(_LATCH, LOW);
delayMicroseconds(5);
}
void ePaper::writeNumberTop(long input)
{
sprintf(topData, "%10ld", input);
createData(topData, topData);
}
void ePaper::writeNumberBottom(long input)
{
sprintf(bottomData, "%10ld", input);
createData(bottomData, bottomData);
}
void ePaper::writeTop(char * characterData)
{
sprintf(topData, "%-10s", characterData);
createData(topData, topData);
}
void ePaper::writeBottom(char * characterData)
{
sprintf(bottomData, "%-10s", characterData);
createData(bottomData, bottomData);
}
void ePaper::writeDisplay()
{
flipData(topData); // If data is not flipped, it will look upside down.
// in the following calls, use WHITE_BG for a white background or
// BLACK_BG for a black background
print(topData, bottomData, WHITE_BG, 1);
delay(100);
print(topData, bottomData, WHITE_BG, 1);
delay(500);
print(topData, bottomData, WHITE_BG, 0);
delay(100);
print(topData, bottomData, WHITE_BG, 0);
}
void ePaper::createData(char * characterData, char * toDisplay)
{
for (int i=0; i<10; i++)
{
int n = chars[toDisplay[i]-32];
for (int j=15; j>=0; j--)
{
characterData[(9-i)*16 + j] = n & 1;
n = n >> 1;
}
}
}
ePaper.h
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef ePaper_h
#define ePaper_h
// Include the standard types
#include <Arduino.h>
// Define the Shifter class
class ePaper
{
public:
// Constructor
ePaper(int EIO1pin, int XCKpin, int LATCHpin, int SLEEPBpin, int DI0pin);
void writeDisplay();
void writeBottom(char * characterData);
void writeTop(char * characterData);
void writeNumberBottom(long input);
void writeNumberTop(long input);
private:
void clock();
void latch();
void print(char * displayTop, char * displayBottom, int bw, int com);
void flipData(char * characterData);
void createData(char * characterData, char * toDisplay);
char topData[160];
char bottomData[160];
char bottomInput[10];
int _EIO;
int _XCK;
int _LATCH;
int _SLPB;
int _DI0;
};
#endif //Shifter_h
keywords.txt
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
#######################################################
# keywords.txt - keywords file for the ePaper library
#######################################################
#######################################
# Datatypes (KEYWORD1)
#######################################
ePaper KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
writeDisplay KEYWORD2
writeBottom KEYWORD2
writeTop KEYWORD2
writeNumberBottom KEYWORD2
writeNumberTop KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
ePaper_Example.ino
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
31
32
33
34
35
36
37
38
39
40
41
#include "ePaper.h" // This file includes defines for each displayable character
int EIOpin = 8; // Input/output pin for chip selection
int XCKpin = 9; // Clock input pin for taking display data
int LATCHpin = 10; // Latch pulse input pin for display data
int SLEEPBpin = 11; // Sleep Pin for the display
int DI0pin = 12; // Input pin for display data
//setup display with pin definitions
ePaper epaper = ePaper(EIOpin, XCKpin, LATCHpin, SLEEPBpin, DI0pin);
void setup(){
Serial.begin(9600);
epaper.writeTop("Random");
epaper.writeBottom("Numbers");
epaper.writeDisplay();
delay(5000);
}
void loop(){
long top = random(2147483646);
long bottom = random(2147483646);
epaper.writeNumberTop(top);
epaper.writeNumberBottom(bottom);
epaper.writeDisplay();
delay(5000);
}
Video
Article taken from bildr.org with minor changes - I am the original author of this content