-
Github!
03/28/2015 at 23:43 • 0 commentsI added the codes to github in case anyone wanted to help me with the coding?
https://github.com/scissorfiend/LED-Matrix-Thing/
Thanks for lookin!
-
Super Stumped! Helps? :D
01/14/2015 at 06:01 • 2 commentsProgramming is hard for me, but I wanted to wait until after the contest to ask for help. For one piece of the jacket I wanted to create a set of modular matrix displays, each with with their own controller board and linked together by a ribbon cables. To the back of this I will add some kind of sealant and then a piece of Velcro to secure it to the jacket. I feel that this makes each display easy to adhere, remove and replace should one break. Please see my circuit below, presently it is built around parts I removed from various thrifted electronics.
Note: Now that the contest is over I am considering breaking my own rule of using only free parts or things had at a thrift store. As you will see the way I am trying to organize the data is esoteric at best, and this is due to the way I have four displays spread across three shift registers, as opposed to giving each display its own shift register which would make coding much simpler. This is solely because I only had 3.
I would like to create a system of stored character bit maps which can be used to make different words and controlled by a serial text string of 8 characters.. Right now I plan to have this string act as instructions for both the character on each Display and its position in a grouping of 8.This string will be processed by a separate function which will load the character map into the appropriate place in a String element, chopped and then shiftOut()'d. This String element would have 16 bits, the first 12 being each anode (plus 4 extra, presently unused) and the final 8 'activating' each of the 7 rows of cathodes plus 1 extra unused. I am planning on having each character map made of four frames due to the nature of the common cathodes of my displays, I feel this is the least amount of frames needed to display more complex letters like Q. I have seen code which lights up each pixel in a bit map individually, however that was with many fewer pixels. All four displays comes to 140 pixels controlled by 20 anodes, one for each column, and 7 common cathodes, one for each row.
This is a pile of very rough mock ups for code which I barely understand. If anyone has any pointers about my overall approach or individual coding techniques, I am welcoming all criticism.
Here is the code I am trying to use to calculate pre made character bit maps ( is that what you call them? ) into shiftable data. Right here I am just sending the data out to the serial monitor so I can play with the concept.
String allOff = String(0b00000000); String allOn = String(0b11111111); String halfOn = String(0b10101010); //String arrayFun[4] = { String(0b10101010), String(0b11111111), String(0b10101010), String(0b00000000) }; String playVal ; int ledPin = 13; byte rowData[4]; byte colData[4]; byte *charframe1Name[7] = { } ; byte charAf1[7] = { B10000000, B00000000, B11000000, B00100000, B10010000, B00001000, B10000000 }; byte charAf2[7] = { B01001000, B00000000, B00001000, B00000000, B01001000, B00000000, B01011000 }; byte charAf3[7] = { B00001000, B00001000, B00001000, B00001000, B00001000, B00000000, B00000000 }; byte charAf4[7] = { B00000000, B00000000, B11110000, B11110000, B11110000, B11110000, B11110000 }; void setup() { Serial.begin(9600); Serial.print(F("Setup")); delay(100); pinMode(ledPin, OUTPUT); } void loop() { while(!Serial.available()) { /* I want this part to eventually shift the array elements into a string for(int i = 0; i < 4; i++) { digitalWrite(ledPin, HIGH); Serial.print(F("playVal : ")); Serial.println(playVal.toInt(), DEC); //int valJar = playVal.toInt(); //Serial.print(F("valJar : ")); //Serial.println(valJar, BIN); playVal += arrayFun[i]; playVal += String("*"); Serial.print(F("allOn : ")); Serial.println(allOn.toInt(), BIN); Serial.print(F("i : ")); Serial.println(i); Serial.print(F("length : ")); Serial.println(playVal.length()); delay(500); digitalWrite(ledPin, LOW); delay(500); } */ Serial.println(F("LOOP")); calculateString(charAf1, 0 ); calculateString(charAf2, 1 ); calculateString(charAf3, 2 ); calculateString(charAf4, 3 ); //Serial.println(String(charCols)); delay(10000); } } //function to convert the character frame bytes into a string byte calculateString(byte* charframe1Name, byte chardataElem){ Serial.println(F("calc")); //check if row is used in frame bitmap and save off or on into for (int y = 0; y < 7; y++) { if (charframe1Name[y] > 1) { bitWrite(rowData[chardataElem], y, 1) ;/// write cathode patterns into rowData array as bytes } else { bitWrite(rowData[chardataElem], y, 0) ; } } //check which columns are used in frame bitmap by ORing all lines together for (int u = 0; u < 7; u++) { colData[chardataElem] |= charframe1Name[u]; } /*really not sure about this, need to do more research. union charMaps { rowData[]; colData[]; } */ //print out the row and column data. Serial.print(F("Char Data Array Element Number: Binary - ")); Serial.println(chardataElem); Serial.print(F("Row Data Array Element Value - ")); Serial.print(rowData[chardataElem], BIN); Serial.print(F(" - Decimal - ")); Serial.println(rowData[chardataElem], DEC); Serial.print(F("Column Data Array Element Value - ")); Serial.print(colData[chardataElem], BIN); Serial.print(F(" - Decimal - ")); Serial.println(colData[chardataElem], DEC); //compare rows among //} // calculate how many different cathode patterns are used //write into for (int z = 0; z < 5; z++) { if (rowData[z+1] == rowData[z]) { rowData[z] = rowData[z+1]; } } }
Here is the code I am using to shift the data out to the displays so far. Note there are inconsistencies between this and the code above, they are not unified and Ithink i broke this text editor..?
havent
whats happening!
figured if I should save the rendered "shiftable bits" into array elements or a string yet. In my mind it will be faster to just shift out array elements populated by a processing function rather than slice them out of a String. Also this code refers to another tab in the Arduino IDE where I am just keeping the character bit maps.//Pin connected to ST_CP of 74HC595 int latchPin = 8; //Pin connected to SH_CP of 74HC595 int clockPin = 12; ////Pin connected to DS of 74HC595s int dataPin = 11;//cathodes int ledPin = 13; byte frameOne[3] ; byte frameTwo[3] ; byte frameThree[3] ; byte frameFour[3] ; //byte 1: cathodes(7s) //byte 2: anodes(5s) Disp 4 and extra //byte 3: anodes(5s) Disp 2, 3 and 4 //byte 4: anodes(5s) Disp 1 and 2 String frame1String = String(0b00000000000000000000000000000000); String frame2String = String(0b00000000000000000000000000000000); String frame3String = String(0b00000000000000000000000000000000); String frame4String = String(0b00000000000000000000000000000000); String frame5String = String(0b00000000000000000000000000000000); String frame6String = String(0b00000000000000000000000000000000); String frame17tring = String(0b00000000000000000000000000000000); String frame28tring = String(0b00000000000000000000000000000000); int sensorPin = A7; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor void setup() { //set pins to output so you can control the shift register pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600); } void loop() { while(!Serial.available()) { digitalWrite(ledPin, LOW); for (int i=0 ; i < 8 ; i++){ digitalWrite(ledPin, LOW); sensorValue = analogRead(sensorPin); //frame 1 digitalWrite(latchPin, LOW); // shift out the bits for frame one: shiftOut(dataPin, clockPin, LSBFIRST, frameOne[1]); //byte 1: cathodes(7s) shiftOut(dataPin, clockPin, LSBFIRST, frameOne[2]); //byte 2: anodes(5s) Disp 4 and extra shiftOut(dataPin, clockPin, LSBFIRST, frameOne[3]); //byte 3: anodes(5s) Disp 2, 3 and 4 shiftOut(dataPin, clockPin, LSBFIRST, frameOne[4]); //byte 4: anodes(5s) Disp 1 and 2 //take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); // pause before showing next frame: delay(1); //frame 2 digitalWrite(latchPin, LOW); // shift out the bits for frame two: shiftOut(dataPin, clockPin, LSBFIRST, frameTwo[1]); //byte 1: cathodes(7s) shiftOut(dataPin, clockPin, LSBFIRST, frameTwo[2]); //byte 2: anodes(5s) Disp 4 and extra shiftOut(dataPin, clockPin, LSBFIRST, frameTwo[3]); //byte 3: anodes(5s) Disp 2, 3 and 4 shiftOut(dataPin, clockPin, LSBFIRST, frameTwo[4]); //byte 4: anodes(5s) Disp 1 and 2 //take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); delay(1); //frame 3 digitalWrite(latchPin, LOW); // shift out the bits for frame two: shiftOut(dataPin, clockPin, LSBFIRST, frameThree[1]); //byte 1: cathodes(7s) shiftOut(dataPin, clockPin, LSBFIRST, frameThree[2]); //byte 2: anodes(5s) Disp 4 and extra shiftOut(dataPin, clockPin, LSBFIRST, frameThree[3]); //byte 3: anodes(5s) Disp 2, 3 and 4 shiftOut(dataPin, clockPin, LSBFIRST, frameThree[4]); //byte 4: anodes(5s) Disp 1 and 2 //take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); delay(1); //frame 4 digitalWrite(latchPin, LOW); // shift out the bits for frame two: shiftOut(dataPin, clockPin, LSBFIRST, frameFour[1]); //byte 1: cathodes(7s) shiftOut(dataPin, clockPin, LSBFIRST, frameFour[2]); //byte 2: anodes(5s) Disp 4 and extra shiftOut(dataPin, clockPin, LSBFIRST, frameFour[3]); //byte 3: anodes(5s) Disp 2, 3 and 4 shiftOut(dataPin, clockPin, LSBFIRST, frameFour[4]); //byte 4: anodes(5s) Disp 1 and 2 //take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); delay(1); } } } void updateFrames (byte dispNo, byte textChar[]) { for(int i = 0; i < 5; i++) { // frameOne[i] = (frame1String ); // frameTwo[i] = (frame2String); // frameThree[i] = (frame3String); } } byte calculateString(byte* charframe1Name){ byte colData[7]; for (byte x; x > 8; x++ ) { for (int y = 0; y < 8; y++) { bitWrite(colData[x],y, bitRead(charframe1Name[x], y)) ; } } }
-
Bitshiftin'
12/17/2014 at 09:30 • 0 commentsMy initial test of my multiple display set up resulted in disaster: Don't hook up your ULN2003 with reverse voltage! Now it just spits out random oscillations on its outputs and such resulting in only one line lighting up. I might also not be understanding how my shiftOut() is working, the order of the bits and such.
More tomorrow when I can get a new uln2003...
Here is my code in case it seems like I am missing anything there?
//Pin connected to ST_CP of 74HC595 int latchPin = 8; //Pin connected to SH_CP of 74HC595 int clockPin = 12; ////Pin connected to DS of 74HC595 int dataPin = 11; int ledPin = 13; byte firstByte[] = { 8, 16, 8,16,8,16, 8, 16}; byte secondByte[] = { 255, 255, 255,255,255,255, 255, 255}; byte thirdByte[] = { 255, 255, 255,255,255,255, 255, 255}; byte fourthByte[] = { 8,8,8,8,8,8,8,8}; // { 0,0,0,0,0,0,0,0 } int sensorPin = A7; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor void setup() { //set pins to output so you can control the shift register pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600); } void loop() { digitalWrite(ledPin, LOW); for (int i=0 ; i < 8 ; i++){ digitalWrite(ledPin, LOW); sensorValue = analogRead(sensorPin); /* Serial.print(F("i")); Serial.println(i); Serial.print(F("First Byte")); Serial.println(firstByte[i]); Serial.print(F("Second Byte")); Serial.println(secondByte[i]); */ digitalWrite(latchPin, LOW); // shift out the bits: shiftOut(dataPin, clockPin, MSBFIRST, firstByte[i]); shiftOut(dataPin, clockPin, MSBFIRST, secondByte[i]); shiftOut(dataPin, clockPin, MSBFIRST, thirdByte[i]); shiftOut(dataPin, clockPin, MSBFIRST, fourthByte[i]); //take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); // pause before next value: delay(sensorValue); //digitalWrite(ledPin, HIGH); /* digitalWrite(ledPin, HIGH); delay(0.001); */ } }
-
New Cool Junk n Stuff
12/17/2014 at 09:19 • 1 commentI have won a Bus Pirate in the random drawing contest! This is awesome because I have always considered buying one and coincidentally purchased one yesterday so I could try to interface with this neat thing I was given at work:
Its a sweet Vizio Bluetooth Remote with QWERTY keyboard! I got it broadcasting as a Bluetooth device, now to find the pin...
-
On to two breadboards now...
12/11/2014 at 08:53 • 0 commentsOnly had a chance to wire it up, letters to com over the weekend.
-
LED Matrix Plan
12/10/2014 at 21:58 • 0 commentsI have decided hoow to set up the Matrix displays and everything so it is easy to use and also repair. I am going to fabricate two boards which will hold 4 displays each as well as all of the required driver components so then I can essentially have them be modules I can hook straight into Trikles. Then I am.going to seal them epoxy or similar and use velcro to attach them to the jacket. This weekend I.might be able to make it out to The Legacy a sewing thrift shop in neighboring Sebastopol, they usually have all kinds of velcro.
-
LED Matrix Fun!
12/10/2014 at 09:23 • 0 commentsI did more testing and was able to get the display to work POV style so I can get crazy with the patterns and text n stuff. Tomorrow I will work on getting multiple displays and actual text but for now, here are two videos I made to demonstrate the effect; One where I fail to demonstrate the principle, and a second where I fail to explain it.
I have the LDR set up to control the speed of the display when flashing between two 'frames (?)' so you can watch the point where the two images blur together :D!
Hear me explain it and almost roast my LDR:
https://drive.google.com/file/d/0B4NTxdyFQRYlSXZYaUEwdV9UZFU/view?usp=sharing
Watch it happen:
https://drive.google.com/file/d/0B4NTxdyFQRYlVU92ekFGT1ZRdVk/view?usp=sharing
Here is my code, again pretty much ripped from the Arduino website. One super important thing you can see is where I commented out all those serial messages, which are handy when debugging but take so much time they prevent you from flashing frames fast enough to confuse ya' brain. Another important part about this code structure is that it isn't really easy to make frames with, however it seems fine with me since I don't want to add more memory for too many animations and I like random patterns.
//Pin connected to ST_CP of 74HC595 int latchPin = 8; //Pin connected to SH_CP of 74HC595 int clockPin = 12; ////Pin connected to DS of 74HC595 int dataPin = 11; int ledPin = 13; byte firstByte[] = { 42,0,42,0,21,0,21,0 }; byte secondByte[] = { 42,255,42,255,21,255,21,255 }; int sensorPin = A7; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor void setup() { //set pins to output so you can control the shift register pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600); } void loop() { digitalWrite(ledPin, LOW); for (int i=0 ; i < 8 ; i++){ sensorValue = analogRead(sensorPin); /* Serial.print(F("i")); Serial.println(i); Serial.print(F("First Byte")); Serial.println(firstByte[i]); Serial.print(F("Second Byte")); Serial.println(secondByte[i]); */ digitalWrite(latchPin, LOW); // shift out the bits: shiftOut(dataPin, clockPin, MSBFIRST, firstByte[i]); shiftOut(dataPin, clockPin, MSBFIRST, secondByte[i]); //take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); // pause before next value: delay(sensorValue/10); /* digitalWrite(ledPin, HIGH); delay(0.001); */ } }
-
LED Matrix & 595 Test
12/09/2014 at 08:50 • 0 commentsHere is a link to the video of an LED matrix display cycling through patterns using code shifted to the 595's from the Trinket.
https://drive.google.com/file/d/0B4NTxdyFQRYlalJTcllnOHJYWlE/view?usp=sharingAt this point I am honestly not sure which bits are corresponding with which pins on the LED matrix, but I am about to actually pay attention to what I am doing and make a drawing. More to come, I hope to get text characters to display before the end of the night!
Here is the code I am using, ripped off from the ShiftOut tutorial on the Arduino site:
//Pin connected to ST_CP of 74HC595 int latchPin = 8; //Pin connected to SH_CP of 74HC595 int clockPin = 12; ////Pin connected to DS of 74HC595 int dataPin = 11; int ledPin = 13; int outputVal = 127; void setup() { //set pins to output so you can control the shift register pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600); } void loop() { digitalWrite(ledPin, LOW); outputVal = 0; for (int i=0 ; i < 256 ; i++){ Serial.println(i); digitalWrite(latchPin, LOW); // shift out the bits: shiftOut(dataPin, clockPin, MSBFIRST, i); shiftOut(dataPin, clockPin, LSBFIRST, i); //take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); // pause before next value: delay(5); //extra fast for dazzlin' digitalWrite(ledPin, HIGH); delay(5); } }