//Bubblelicious test
#include <SPI.h>
byte ssPin = 9;
byte fontArray[] = {
// dp-a-b-c-d-e-f-g
0b01111110, // 0
0b00110000, // 1
0b01101101, // 2
0b01111001, // 3
0b00110011, // 4
0b01101101, // 5
0b01101111, // 6
0b01110000, // 7
0b01111111, // 8
0b01111011, // 9
0b01110111, // 10 A
0b00111101, // 11 d
0b01001111, // 12 E
0b00110111, // 13 H
0b00010000, // 14 i
0b00001110, // 15 L
0b00010101, // 16 n
0b00000101, // 17 r
0b00011100, // 18 u
0b00011101, // 19 o
0b00000000, // 20 blank
};
byte messageArray[] = {
13,12,15,15, 0,20, 4,20, // HELLO 4
10,17,11,18,14,16,19,20, // Arduino
};
byte Noop = 0x00;
byte decodeReg = 0x09;
byte normalReg = 0x0c;
byte displayReg = 0x0f;
byte scanReg = 0x0b;
byte intensityReg = 0x0a;
byte digits[] = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,};
byte x;
void setup(){
SPI.begin();
digitalWrite (ssPin, LOW);
SPI.transfer (intensityReg);
SPI.transfer (0x06);
digitalWrite (ssPin, HIGH);
digitalWrite (ssPin, LOW);
SPI.transfer (decodeReg);
SPI.transfer (0x00); // no decode for all digits
digitalWrite (ssPin, HIGH);
digitalWrite (ssPin, LOW);
SPI.transfer (scanReg);
SPI.transfer (0x07); // all 7 digits
digitalWrite (ssPin, HIGH);
digitalWrite (ssPin, LOW);
SPI.transfer (displayReg);
SPI.transfer (0x00); // normal operation
digitalWrite (ssPin, HIGH);
digitalWrite (ssPin, LOW);
SPI.transfer (normalReg);
SPI.transfer (0x01); // normal mode
digitalWrite (ssPin, HIGH);
}
void loop(){
for (x=0; x<8; x=x+1){
digitalWrite (ssPin, LOW);
SPI.transfer(digits[x]);
//SPI.transfer (0x01);
SPI.transfer (1<<x);
// SPI.transfer (fontArray[messageArray[x]]);
digitalWrite (ssPin, HIGH);
}
delay (750);
for (x=0; x<8; x=x+1){
digitalWrite (ssPin, LOW);
SPI.transfer(digits[x]);
//SPI.transfer(0x00);
SPI.transfer (fontArray[messageArray[x+8]]);
digitalWrite (ssPin, HIGH);
}
delay (750);
}