From 967f64c935de9107d3109ecfa30fc34ff13e290c Mon Sep 17 00:00:00 2001 From: georges Date: Sun, 4 Aug 2013 03:23:22 +0100 Subject: [PATCH] test with 4 elements 7segment display problems with the latch --- PoC/7seg/7segmentdesign.xls | Bin 0 -> 22016 bytes PoC/7seg/display4/display4.ino | 143 +++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 PoC/7seg/7segmentdesign.xls create mode 100644 PoC/7seg/display4/display4.ino diff --git a/PoC/7seg/7segmentdesign.xls b/PoC/7seg/7segmentdesign.xls new file mode 100644 index 0000000000000000000000000000000000000000..80678878b1bc0b43e8e7fd552fc5e625effeddcd GIT binary patch literal 22016 zcmeI4Ym8mjRmbfEp7BgPkJy>Vjgxt0#-4}WB!w1Fl5ro15-TZ?LZ!xW#<5!` zt{gXNKNO~geyBvGluAKURYDc{0!XD*QIIGoH-Zlc%tMiiTEvG0At3~!E&`!SZHE7E z@4MFCXE>&Ius~^Z@0|NTci+ADTK{$S{;z$`oO}QJuZCXz(pL|?7Ir*-JamQExA%ly zMR`N}bM}5PglX+l_WJhrwiRplt;d@v0^jfW+NA^7t*u8J$9%W8UTu4{?bX(&ZJ)M& zZ3Ei&Yts-2L)vc9c0k*(wh?Wk+Qziqs_me*L)vcBHm+?#+oZNBZ7prLYdfs%4sCa8 zV=S@FcJ}8x_$CVJo66OP!bLqV>sXu&PYExDPblKo{}|PXDG6Us%Th0{r~VJB^OpS_ zfgcnrJ}=|Hr&qIhS5NqQ{}rZuocphZX820?%X$sr@3nm}d=zbX;Pizvt^cdX{n3Zh z4SZ-T$-J|%OSz`0tn@{_4us#0pZsBbeP>i4Ra^_Ldj({rN1AJ@7s9jg^>BP0&}$?7 zer)r%v1CQs^rxz|{Y%fu21PxM`!om6htuIg*zu_<+^kP0yZ40`(AamM{OOYq-S< zwtr3YG>v>IL5Pd7&I>EESfZUxh;?2zg`2$5PP^R}Y=*6^?XY$1tn~a!xT5-J_1so@ zIIH(p=uj^4WHIsqENR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X~yTLw9)brZLC8!wJ`_&L>qO!sg1G!58C+sv#Z*qx8Zx* zxa`^6asHpaAG9`0+dZv^H=cNMGb7`mpXOcA$;J{ z#_7u&Pq*$l@^q*E8LR(v>-1BPw?2C5;xp$TSB=Z(Hd>EwoH_sG=?krAPG9)gMzn=r zKY8)#jn=92PhITv3zrpbYufCwrk%~Ned5pm=(a!Or$)l&sn7oA*E{=Rap;-fe(o;` z#T$NHEB^S>{Kj8=)2-zdcFLKmwp8xK6=8s nES!lxY{Xw6yfJ_7eFOZ__RGoqO?kc1_?N%GcQYLL-`M{zao~0z literal 0 HcmV?d00001 diff --git a/PoC/7seg/display4/display4.ino b/PoC/7seg/display4/display4.ino new file mode 100644 index 0000000..847f528 --- /dev/null +++ b/PoC/7seg/display4/display4.ino @@ -0,0 +1,143 @@ +// Arduino 7 segment x 4 display + +// Define the LED digit patters, from 0 - 9 + +// segment layout +// 0 +// 5 1 +// 6 +// 4 2 +// 3 7 + +// steve layout +// 1 +// 3 2 +// 4 +// 6 0 +// 5 7 + +byte steve_converter(byte inval) { + byte outval=0; + outval|=(inval & 0x1)<<1; // seg 0 goes to 1 (plus 1) + outval|=(inval & 0x2)<<1; // seg 1 goes to 2 (plus 1) + outval|=(inval & 0x4)>>2; // seg 2 goes to 0 (minus 2) + outval|=(inval & 0x8)<<2; // seg 3 goes to 5 (plus 2) + outval|=(inval & 0x10)<<2; // seg 4 goes to 6 (plus 2) + outval|=(inval & 0x20)>>2; // seg 5 goes to 3 (minus 2) + outval|=(inval & 0x40)>>2; // seg 6 goes to 4 (minus 2) + outval|=(inval & 0x80); // dot 7 stays + return outval; +} + +byte seven_seg_digits[10][7] = { { 1,1,1,1,1,1,0 }, // = 0 + { 0,1,1,0,0,0,0 }, // = 1 + { 1,1,0,1,1,0,1 }, // = 2 + { 1,1,1,1,0,0,1 }, // = 3 + { 0,1,1,0,0,1,1 }, // = 4 + { 1,0,1,1,0,1,1 }, // = 5 + { 1,0,1,1,1,1,1 }, // = 6 + { 1,1,1,0,0,0,0 }, // = 7 + { 1,1,1,1,1,1,1 }, // = 8 + { 1,1,1,0,0,1,1 } // = 9 + }; +// http://www.josepino.com/microcontroller/7-segment-ascii +// http://www.raspberrypi.org/phpBB3/viewtopic.php?t=13645&p=142539 +uint8_t ascii2segments[] = { + 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x02, /* ! " # $ % & ' */ + 0x80, 0x0f, 0x80, 0x80, 0x04, 0x40, 0x80, 0x80, /* ( ) * + , - . / */ + 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, /* 0 1 2 3 4 5 6 7 */ + 0x7F, 0x6F, 0x80, 0x80, 0x80, 0x48, 0x80, 0x27, /* 8 9 : ; < = > ? */ + 0x80, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x3d, /* @ A B C D E F G */ + 0x76, 0x30, 0x1E, 0x76, 0x38, 0x15, 0x37, 0x3f, /* H I J K L M N O */ + 0x73, 0x67, 0x31, 0x6d, 0x78, 0x3e, 0x1C, 0x2A, /* P Q R S T U V W */ + 0x76, 0x6e, 0x5b, 0x39, 0x80, 0x0F, 0x80, 0x08, /* X Y Z [ \ ] ^ _ */ + 0x80, 0x5f, 0x7c, 0x58, 0x5e, 0x7b, 0x71, 0x6F, /* ` a b c d e f g */ + 0x74, 0x30, 0x0E, 0x76, 0x06, 0x15, 0x54, 0x5c, /* h i j k l m n o */ + 0x73, 0x67, 0x50, 0x6d, 0x78, 0x1c, 0x1c, 0x2A, /* p q r s t u v w */ + 0x76, 0x6e, 0x5b, 0x39, 0x80, 0x0F, 0x80, 0x08, /* x y z { | } ~ */ +}; + +//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; + + +void setup() { + //Start Serial for debuging purposes + Serial.begin(9600); + //set pins to output because they are addressed in the main loop + pinMode(latchPin, OUTPUT); + // shiftOut(dataPin, clockPin, steve_converter(1<<7)); +} + +void shiftOut(int myDataPin, int myClockPin, byte myDataOut) { + // This shifts 8 bits out MSB first, + //on the rising edge of the clock, + //clock idles low + + //internal function setup + int i=0; + int pinState; + pinMode(myClockPin, OUTPUT); + pinMode(myDataPin, OUTPUT); + + //clear everything out just in case to + //prepare shift register for bit shifting + digitalWrite(myDataPin, 0); + digitalWrite(myClockPin, 0); + + //for each bit in the byte myDataOut� + //NOTICE THAT WE ARE COUNTING DOWN in our for loop + //This means that %00000001 or "1" will go through such + //that it will be pin Q0 that lights. + for (i=7; i>=0; i--) { + digitalWrite(myClockPin, 0); + + //if the value passed to myDataOut and a bitmask result + // true then... so if we are at i=6 and our value is + // %11010100 it would the code compares it to %01000000 + // and proceeds to set pinState to 1. + if ( myDataOut & (1<