Hey guys,
First post here so I don’t really know what I’m doing. Sorry, this will be really dumb but I really hope you can help!
So I pulled apart an old alarm clock. I pulled out the 7 segment display and I have been trying to figure out how to use it with an Arduino. Bottom line, I can’t figure it out. The controller is TM1629A, the closest English data sheet I found is here. I also translated the actual Chinese one to English, so if you can be bothered that’s here.
This is my sketch:
int clk = 8;
int data = 7;
int count = 0;
int temp = 0;
int raw[8] = {1,0,1,0,1,0,1,0};
void setup() {
pinMode(clk, OUTPUT);
pinMode(data, OUTPUT);
pinMode(6, OUTPUT);
digitalWrite(6, HIGH);
Serial.begin(9600);
//convert();
//execute();
Serial.println(raw[0]);
}
void loop() {
handleSerial();
delay(100);
/*for(int i = 0; i < 8; i++)
{
Serial.println(raw[i]);
}*/
execute();
delay(1000);
}
void handleSerial() {
int check = 0;
int incomingCharacter;
for (int i=0; i< 8; i++) {
while (check < 8) {
incomingCharacter = Serial.read();
if (incomingCharacter != -1) {
//Serial.println(incomingCharacter);
}
if (incomingCharacter == 49) {
raw[i] = 1;
check++;
break;
}
else if (incomingCharacter == 48) {
raw[i] = 0;
check++;
break;
}
else if (incomingCharacter == 114) {
check = 0;
i = 0;
Serial.println("Resetting... Done.");
}
delay(5);
}
}
}
void execute() {
Serial.print("Sending: ");
for (int i = 0; i < 8; i++) {
//Serial.print(dat[i]);
if (raw[i] == 0){
digitalWrite(clk, LOW);
delay(1);
digitalWrite(data, LOW);
digitalWrite(clk, HIGH);
Serial.print("0");
}
else if (raw[i] == 1) {
digitalWrite(clk, LOW);
delay(1);
digitalWrite(data, HIGH);
digitalWrite(clk, HIGH);
Serial.print("1");
}
else if (raw[i] != 1 && raw[i] != 0){
Serial.println(raw[i] + " is an invalid character in string. Terminating...");
break;
}
delay(50);
digitalWrite(data, LOW);
delay(50);
}
Serial.println();
Serial.println("Success");
Serial.println();
}
Essentially, using the serial moniter you can provide as many bytes as you like to send to the data pin of the controller. I’ve just been trying to send commands listed in the data sheet but it doesn’t seem to do anything. I don’t know if I have hooked something up wrong or is there a better way I could approach this?
Here are a couple of images of the display and board: Imgur: The magic of the Internet.
In the second photo, the connections are labeled (not in picture) from left to right (top to bottom), VCC, GND, CLK, DAt, 3.3, CS, IR.
Out of these, I don’t understand what the 3.3 (I guessed it just wanted a 3.3V input but idk) and CS pins are for.
I would like to learn how to turn on and off each segment.
If anyone could help me out at all, I’d be indebted to you. Thank you in advance!