Dima
Published © LGPL

Custom Output from Alarm Clock Ceiling Projector

My process for figuring out how to make the LED/LCD projector from an alarm clock output whatever I want.

IntermediateFull instructions provided2,185
Custom Output from Alarm Clock Ceiling Projector

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
MS-CR1001 Alarm Clock
×1
Jumper wires (generic)
Jumper wires (generic)
×5

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Or another way of joining two wires.
Multimeter

Story

Read more

Schematics

Wiring diagram

Where to connect the five wires from the circuit board to the Arduino

Code

Make the projector cycle through A, b, c, d, then clear them all

Arduino
int latchPin = 5; // white
int clkPin = 6; // blue
int dataPin = 4; // yellow

//Write command code
unsigned long comWr = 0b101;

//All the commands
unsigned long lcdOn = 0b100000000110;
unsigned long lcdOff = 0b100000000100;

unsigned long toneOn =  0b100000010010;
unsigned long toneOff = 0b100000010000;


unsigned long tone4k = 0b100010000000;
unsigned long tone2k = 0b100011000000;

unsigned long sysDis =    0b100000000000;
unsigned long sysEn =     0b100000000010;
unsigned long timerDis =  0b100000001000;
unsigned long timerEn =   0b100000001100;
unsigned long wdtDis =    0b100000001010;
unsigned long wdtEn =     0b100000001110;
unsigned long clrTimer =  0b100000011000;
unsigned long clrWdt =    0b100000011100;
unsigned long xtal32k =   0b100000101000;
unsigned long rc256k =    0b100000110000;
unsigned long ext256k =   0b100000111000;

unsigned long bias12x2 =  0b100001000000;
unsigned long bias12x3 =  0b100001001000;
unsigned long bias12x4 =  0b100001010000;

unsigned long bias13x2 =  0b100001000010;
unsigned long bias13x3 =  0b100001001010;
unsigned long bias13x4 =  0b100001010010;

unsigned long irqDis =    0b100100000000;
unsigned long irqEn =     0b100100010000;

unsigned long f1 =        0b100101000000;
unsigned long f2 =        0b100101000010;
unsigned long f4 =        0b100101000100;
unsigned long f8 =        0b100101000110;
unsigned long f16 =       0b100101001000;
unsigned long f32 =       0b100101001010;
unsigned long f64 =       0b100101001100;
unsigned long f128 =      0b100101001110;

unsigned long test =      0b100111000000;
unsigned long normal =    0b100111000110;

//Since each digit is composed of two addresses, I have each letter as an array of the two COM designations. I would do the same for the numbers 1-9 or any other symbols I would need.
int a[2] = {0b1110, 0b1110};
int b[2] = {0b1111, 0b0010};
int c[2] = {0b0111, 0b0000};
int d[2] = {0b0111, 0b0110};

//A nested array for the addresses for each digit. 
//For example digit[1][0] would give you the first address of the second digit.
//digit[1][1] would give you the second address of the second digit.
int digit[4][2] = {{24, 25}, {26, 27}, {28, 29}, {30, 31}};

//To make an "A", you would send these two commands:
//lcdShift(comWr*1024 + digit[0][0]*16 + a[0]);
//lcdShift(comWr*1024 + digit[0][1]*16 + a[1]);

//The *1024 and *16 put the command and address, respectively, in the correct place in the final binary command.
//The first function would send the binary number, 101 011000 1110 (without the spaces).


//Send a data stream to the chip.
//Takes a binary number of any length.
void lcdShift(unsigned long data){
  
  unsigned long bit = 1;
  
  int i;
  int len = (int)(log(data)/log(2))+1;
  unsigned long chck = bit<<(len-1);
  
  digitalWrite(latchPin,LOW);
  
  for(i = 0; i < len; i++){
    digitalWrite(clkPin,LOW);
    
    digitalWrite(dataPin,((chck&(data<<i)) == chck) ? HIGH : LOW);
    delayMicroseconds(10);
    
    digitalWrite(clkPin,HIGH);
    delayMicroseconds(10);
  }

  digitalWrite(latchPin,HIGH);

}

//Turns off all the segments
void clearAll(){
  long i;
  for (i=31;i>23;i--){
    lcdShift(comWr*1024 + i*16 + 0b0000);
    delay(100);
  }
}

//Turns off the segments of a single digit.
void clearDigit(int dig){
  lcdShift(comWr*1024 + digit[dig][0]*16 + 0b0000);
  lcdShift(comWr*1024 + digit[dig][1]*16 + 0b0000);
}


void setup() 
{ 
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clkPin, OUTPUT);  

  //The apparently necessary commands.
  lcdShift(normal);
  lcdShift(lcdOn);
  lcdShift(xtal32k);
  lcdShift(sysEn);
  lcdShift(bias13x4);

}

//Loops "Abcd"
void loop() 
{  

  lcdShift(comWr*1024 + digit[0][0]*16 + a[0]);
  lcdShift(comWr*1024 + digit[0][1]*16 + a[1]);

  delay(1000);

  lcdShift(comWr*1024 + digit[1][0]*16 + b[0]);
  lcdShift(comWr*1024 + digit[1][1]*16 + b[1]);

  delay(1000);

  lcdShift(comWr*1024 + digit[2][0]*16 + c[0]);
  lcdShift(comWr*1024 + digit[2][1]*16 + c[1]);

  delay(1000);

  lcdShift(comWr*1024 + digit[3][0]*16 + d[0]);
  lcdShift(comWr*1024 + digit[3][1]*16 + d[1]);

  delay(1000);

  clearAll();

  delay(1000);

  /*
   
  COM assignments for the different segments.

  --Even addresses (24, 26, 28, 30)
  bottom        0001
  bottom left   0010
  middle        0100
  top left      1000

  --Odd addresses (25, 27, 29, 31)
  bottom right  0010
  top right     0100
  top           1000

  --Other segments
  colon         29x0001
  top PM        31x0001
  bottom PM     25x0001
  
  */
  
}

Credits

Dima

Dima

0 projects • 0 followers

Comments