// This is not a working sketch yet !
unsigned long lastDTime = 0;
#define HMDelay 320
const byte characters[] = {
0b00111111,// 0
0b00000110,// 1
0b01011011,// 2
0b01001111,// 3
0b01100110,// 4
0b01101101,// 5
0b01111101,// 6
0b00000111,// 7
0b01111111,// 8
0b01100111,// 9
0b01110111,// A
0b01111100,// B
0b00111001,// C
0b01011110,// D
0b01111001,// E
0b01110001,// F
0b10001000 // DP
};
void tglCLOCK(bool a) {
DDRB = B01000000;
if(a == true){
PORTB = B01000000;
}
else if(a == false){
PORTB = B00000000;
}
}
void tglLATCH(bool a) {
DDRB = B10000000;
if(a == true){
PORTB = B10000000;
}
else if(a == false){
PORTB = B00000000;
}
}
void tglDATA(bool a) {
DDRB = B00000100;
if(a == true){
PORTB = B00000100;
}
else if(a == false){
PORTB = B00000000;
}
}
/*
void shiftingBits(byte B) {
for (int i = 0; i < 8; i ++) {
if ((B >> i) & (0x01)) {
tglDATA();
tglCLOCK();
}
tglLATCH();
}
}
*/
void BitBang(const char b){
tglLATCH(false);
int mask = 0x80;
for(int i = 0; i < 8; i++){
if(b && mask != 0){
tglDATA(true);
}
else{
tglDATA(false);
}
tglCLOCK(true);
b<<1;
tglCLOCK(false);
}
tglLATCH(true);
}
void HeartBeat() {
lastDTime = millis();
if ((millis() - lastDTime) > HMDelay) {
BitBang(characters[16]);
}
}
void setup() {
DDRB = B00000001;
tglCLOCK(false);
tglLATCH(false);
}
void loop() {
HeartBeat();
tglLATCH(true);
}