Coffee Space


Listen:

Home Brew Watch

With Apple recently announcing their horrible smart watch, I thought it’s only fair if hardware hobbyists also get the chance to build their own. Obviously being a student at current it can’t be too expensive. Where possible, I have cut corners to the extreme to try and make sure I don’t break the bank with this little experiment and more importantly so that others can do it too.

I’ll aim to add to this project when I learn more about what I’m actually doing and as with all of this, when I get spare time!

Parts List

The following parts were used in the construction of this device:

Main Controller

Picture of Digispark

Image from Digistump.com, the official location for Digispark.

I wanted to make sure it was quick to get up and running with this project without having to deal with more hardware based issues I was already going to have to contend with. For this, it made sense to use an Arduino based project as experience with these in the past has always been great!

After working in the industry for a while, I decided the Digispark was nice and under powered for what I needed - so that would do the trick! The Digispark has a nice little Atmel Attiny85 MCU, which although fast offers only a small 6KB of programming space after the bootloader. If this wasn’t enough, I bought a Nokia 5110 screen, with 8 pins on it including VCC and GND, which would be okay if the Digispark had 6 pins where 2 of them weren’t for USB! A challenge…

Pin Out

TODO: Pin out to be updated soon…

Code

This is the code I have so far, it’s a work in progress as everything is but it should work reasonably well… As you can probably tell, it doesn’t actually do it’s job yet!

0001 /*
0002 Scrolling text example code
0003 Modified from: http://www.arduino.cc/playground/Code/PCD8544
0004 */
0005 
0006 // The pins to use on the arduino
0007 #define PIN_BACK  4
0008 #define PIN_RESET 5//6
0009 #define PIN_DC    2//5
0010 #define PIN_SDIN  1//4
0011 #define PIN_SCLK  0//3
0012 
0013 // Configuration for the LCD
0014 #define LCD_C     LOW
0015 #define LCD_D     HIGH
0016 #define LCD_CMD   0
0017 
0018 // Size of the LCD
0019 #define LCD_X     84
0020 #define LCD_Y     48
0021 
0022 int scrollPosition = -10;
0023 
0024 static const byte ASCII[][5] =
0025 {
0026  {0x00, 0x00, 0x00, 0x00, 0x00} // 20
0027 ,{0x00, 0x00, 0x5f, 0x00, 0x00} // 21 !
0028 ,{0x00, 0x07, 0x00, 0x07, 0x00} // 22 "
0029 ,{0x14, 0x7f, 0x14, 0x7f, 0x14} // 23 #
0030 ,{0x24, 0x2a, 0x7f, 0x2a, 0x12} // 24 $
0031 ,{0x23, 0x13, 0x08, 0x64, 0x62} // 25 %
0032 ,{0x36, 0x49, 0x55, 0x22, 0x50} // 26 &
0033 ,{0x00, 0x05, 0x03, 0x00, 0x00} // 27 '
0034 ,{0x00, 0x1c, 0x22, 0x41, 0x00} // 28 (
0035 ,{0x00, 0x41, 0x22, 0x1c, 0x00} // 29 )
0036 ,{0x14, 0x08, 0x3e, 0x08, 0x14} // 2a *
0037 ,{0x08, 0x08, 0x3e, 0x08, 0x08} // 2b +
0038 ,{0x00, 0x50, 0x30, 0x00, 0x00} // 2c ,
0039 ,{0x08, 0x08, 0x08, 0x08, 0x08} // 2d -
0040 ,{0x00, 0x60, 0x60, 0x00, 0x00} // 2e .
0041 ,{0x20, 0x10, 0x08, 0x04, 0x02} // 2f /
0042 ,{0x3e, 0x51, 0x49, 0x45, 0x3e} // 30 0
0043 ,{0x00, 0x42, 0x7f, 0x40, 0x00} // 31 1
0044 ,{0x42, 0x61, 0x51, 0x49, 0x46} // 32 2
0045 ,{0x21, 0x41, 0x45, 0x4b, 0x31} // 33 3
0046 ,{0x18, 0x14, 0x12, 0x7f, 0x10} // 34 4
0047 ,{0x27, 0x45, 0x45, 0x45, 0x39} // 35 5
0048 ,{0x3c, 0x4a, 0x49, 0x49, 0x30} // 36 6
0049 ,{0x01, 0x71, 0x09, 0x05, 0x03} // 37 7
0050 ,{0x36, 0x49, 0x49, 0x49, 0x36} // 38 8
0051 ,{0x06, 0x49, 0x49, 0x29, 0x1e} // 39 9
0052 ,{0x00, 0x36, 0x36, 0x00, 0x00} // 3a :
0053 ,{0x00, 0x56, 0x36, 0x00, 0x00} // 3b ;
0054 ,{0x08, 0x14, 0x22, 0x41, 0x00} // 3c <
0055 ,{0x14, 0x14, 0x14, 0x14, 0x14} // 3d =
0056 ,{0x00, 0x41, 0x22, 0x14, 0x08} // 3e >
0057 ,{0x02, 0x01, 0x51, 0x09, 0x06} // 3f ?
0058 ,{0x32, 0x49, 0x79, 0x41, 0x3e} // 40 @
0059 ,{0x7e, 0x11, 0x11, 0x11, 0x7e} // 41 A
0060 ,{0x7f, 0x49, 0x49, 0x49, 0x36} // 42 B
0061 ,{0x3e, 0x41, 0x41, 0x41, 0x22} // 43 C
0062 ,{0x7f, 0x41, 0x41, 0x22, 0x1c} // 44 D
0063 ,{0x7f, 0x49, 0x49, 0x49, 0x41} // 45 E
0064 ,{0x7f, 0x09, 0x09, 0x09, 0x01} // 46 F
0065 ,{0x3e, 0x41, 0x49, 0x49, 0x7a} // 47 G
0066 ,{0x7f, 0x08, 0x08, 0x08, 0x7f} // 48 H
0067 ,{0x00, 0x41, 0x7f, 0x41, 0x00} // 49 I
0068 ,{0x20, 0x40, 0x41, 0x3f, 0x01} // 4a J
0069 ,{0x7f, 0x08, 0x14, 0x22, 0x41} // 4b K
0070 ,{0x7f, 0x40, 0x40, 0x40, 0x40} // 4c L
0071 ,{0x7f, 0x02, 0x0c, 0x02, 0x7f} // 4d M
0072 ,{0x7f, 0x04, 0x08, 0x10, 0x7f} // 4e N
0073 ,{0x3e, 0x41, 0x41, 0x41, 0x3e} // 4f O
0074 ,{0x7f, 0x09, 0x09, 0x09, 0x06} // 50 P
0075 ,{0x3e, 0x41, 0x51, 0x21, 0x5e} // 51 Q
0076 ,{0x7f, 0x09, 0x19, 0x29, 0x46} // 52 R
0077 ,{0x46, 0x49, 0x49, 0x49, 0x31} // 53 S
0078 ,{0x01, 0x01, 0x7f, 0x01, 0x01} // 54 T
0079 ,{0x3f, 0x40, 0x40, 0x40, 0x3f} // 55 U
0080 ,{0x1f, 0x20, 0x40, 0x20, 0x1f} // 56 V
0081 ,{0x3f, 0x40, 0x38, 0x40, 0x3f} // 57 W
0082 ,{0x63, 0x14, 0x08, 0x14, 0x63} // 58 X
0083 ,{0x07, 0x08, 0x70, 0x08, 0x07} // 59 Y
0084 ,{0x61, 0x51, 0x49, 0x45, 0x43} // 5a Z
0085 ,{0x00, 0x7f, 0x41, 0x41, 0x00} // 5b [
0086 ,{0x02, 0x04, 0x08, 0x10, 0x20} // 5c ¥
0087 ,{0x00, 0x41, 0x41, 0x7f, 0x00} // 5d ]
0088 ,{0x04, 0x02, 0x01, 0x02, 0x04} // 5e ^
0089 ,{0x40, 0x40, 0x40, 0x40, 0x40} // 5f _
0090 ,{0x00, 0x01, 0x02, 0x04, 0x00} // 60 `
0091 ,{0x20, 0x54, 0x54, 0x54, 0x78} // 61 a
0092 ,{0x7f, 0x48, 0x44, 0x44, 0x38} // 62 b
0093 ,{0x38, 0x44, 0x44, 0x44, 0x20} // 63 c
0094 ,{0x38, 0x44, 0x44, 0x48, 0x7f} // 64 d
0095 ,{0x38, 0x54, 0x54, 0x54, 0x18} // 65 e
0096 ,{0x08, 0x7e, 0x09, 0x01, 0x02} // 66 f
0097 ,{0x0c, 0x52, 0x52, 0x52, 0x3e} // 67 g
0098 ,{0x7f, 0x08, 0x04, 0x04, 0x78} // 68 h
0099 ,{0x00, 0x44, 0x7d, 0x40, 0x00} // 69 i
0100 ,{0x20, 0x40, 0x44, 0x3d, 0x00} // 6a j
0101 ,{0x7f, 0x10, 0x28, 0x44, 0x00} // 6b k
0102 ,{0x00, 0x41, 0x7f, 0x40, 0x00} // 6c l
0103 ,{0x7c, 0x04, 0x18, 0x04, 0x78} // 6d m
0104 ,{0x7c, 0x08, 0x04, 0x04, 0x78} // 6e n
0105 ,{0x38, 0x44, 0x44, 0x44, 0x38} // 6f o
0106 ,{0x7c, 0x14, 0x14, 0x14, 0x08} // 70 p
0107 ,{0x08, 0x14, 0x14, 0x18, 0x7c} // 71 q
0108 ,{0x7c, 0x08, 0x04, 0x04, 0x08} // 72 r
0109 ,{0x48, 0x54, 0x54, 0x54, 0x20} // 73 s
0110 ,{0x04, 0x3f, 0x44, 0x40, 0x20} // 74 t
0111 ,{0x3c, 0x40, 0x40, 0x20, 0x7c} // 75 u
0112 ,{0x1c, 0x20, 0x40, 0x20, 0x1c} // 76 v
0113 ,{0x3c, 0x40, 0x30, 0x40, 0x3c} // 77 w
0114 ,{0x44, 0x28, 0x10, 0x28, 0x44} // 78 x
0115 ,{0x0c, 0x50, 0x50, 0x50, 0x3c} // 79 y
0116 ,{0x44, 0x64, 0x54, 0x4c, 0x44} // 7a z
0117 ,{0x00, 0x08, 0x36, 0x41, 0x00} // 7b {
0118 ,{0x00, 0x00, 0x7f, 0x00, 0x00} // 7c |
0119 ,{0x00, 0x41, 0x36, 0x08, 0x00} // 7d }
0120 ,{0x10, 0x08, 0x08, 0x10, 0x08} // 7e ←
0121 ,{0x00, 0x06, 0x09, 0x09, 0x06} // 7f →
0122 };
0123 
0124 void LcdCharacter(char character){
0125   LcdWrite(LCD_D, 0x00);
0126   for(int index = 0; index < 5; index++)
0127     LcdWrite(LCD_D, ASCII[character - 0x20][index]);
0128   LcdWrite(LCD_D, 0x00);
0129 }
0130 
0131 void LcdClear(void){
0132   for(int index = 0; index &lt; LCD_X * LCD_Y / 8; index++)
0133     LcdWrite(LCD_D, 0x00);
0134 }
0135 
0136 void LcdInitialise(void){
0137   pinMode(PIN_BACK,  OUTPUT);
0138   pinMode(PIN_RESET, OUTPUT);
0139   pinMode(PIN_DC,    OUTPUT);
0140   pinMode(PIN_SDIN,  OUTPUT);
0141   pinMode(PIN_SCLK,  OUTPUT);
0142   
0143   digitalWrite(PIN_RESET, LOW);
0144   digitalWrite(PIN_RESET, HIGH);
0145   
0146   LcdWrite(LCD_CMD, 0x21);  // LCD Extended Commands.
0147   LcdWrite(LCD_CMD, 0x98);  // Set LCD Vop (Contrast). //B1
0148   LcdWrite(LCD_CMD, 0x04);  // Set Temp coefficent. //0x04
0149   LcdWrite(LCD_CMD, 0x14);  // LCD bias mode 1:48. //0x13
0150   LcdWrite(LCD_CMD, 0x0C);  // LCD in normal mode. 0x0d for inverse
0151   LcdWrite(LCD_C, 0x20);
0152   LcdWrite(LCD_C, 0x0C);
0153 }
0154 
0155 void LcdString(char *characters){
0156   while (*characters){
0157     LcdCharacter(*characters++);
0158   }
0159 }
0160 
0161 void LcdWrite(byte dc, byte data){
0162   digitalWrite(PIN_DC, dc);
0163   shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data);
0164 }
0165 
0166 /**
0167  * gotoXY routine to position cursor
0168  * x - range: 0 to 84
0169  * y - range: 0 to 5
0170  **/
0171 void gotoXY(int x, int y){
0172   LcdWrite( 0, 0x80 | x);  // Column.
0173   LcdWrite( 0, 0x40 | y);  // Row.
0174 }
0175 
0176 void drawBox(void){
0177   int j;
0178   for(j = 0; j &lt; 84; j++){ // top
0179     gotoXY(j, 0);
0180     LcdWrite(1, 0x01);
0181   }
0182   
0183   for(j = 0; j &lt; 84; j++){ //Bottom
0184     gotoXY(j, 5);
0185     LcdWrite(1, 0x80);
0186   }
0187   
0188   for(j = 0; j &lt; 6; j++){ // Right
0189     gotoXY(83, j);
0190     LcdWrite(1, 0xff);
0191   }
0192   
0193   for(j = 0; j &lt; 6; j++){ // Left
0194     gotoXY(0, j);
0195     LcdWrite(1, 0xff);
0196   }
0197 }
0198 
0199 void setup(void){
0200   LcdInitialise();
0201   LcdClear();
0202   drawBox();
0203   
0204   gotoXY(5,1);
0205   LcdString("><><><><><><");
0206   gotoXY(5,2);
0207   LcdString("B[]Arrayx");;
0208 }
0209 
0210 void loop(void){
0211   gotoXY(5,3);
0212   int mins = millis() / 1000;
0213   String val = String(mins);
0214   val += "\0";
0215   char buffer[10];
0216   val.toCharArray(buffer, 10u);
0217   LcdString(buffer);
0218   digitalWrite(PIN_BACK, HIGH);
0219   delay(250);
0220 }