2010年7月4日日曜日

7 segment with Shift Resistors

I did a test of controlling 7 segment with Shift resistor 8-Bit - 74HC595.

I finally control two 7 segment with two Shift resistor 8-Bit - 74HC595.


Tutorial

Shift resistor 8-Bit - 74HC595 is very useful since Arduino have only 13 digital pins we may need more pins to make a more complex controller.

7 segment is one of a example that need a lot of pins to control.

So that I will explain Shift resistor 8-Bit - 74HC595 with two 7 segment.



Requirement

Shift Resistor 8-Bit - 74HC595

Two 7 segment

A lot of wires

14 220Ohm resistors

Breadboards(At least you need one large  Breadboard) I use one  Breadboard and two small  Breadboard.

Arduino

Arduino program

computer with USB

Calculator (you need to change decimal to binary)

Circuit

latchPin is 8.

clockPin is 12.

dataPin is 11.



When you send a value with ShiftOut, the value which transformed into
a binary data will conrespond to the red pin(Q0 ~ Q7).
Since this is a 8 bit shift resistor, the range of the value will be 0~255.
(2x2x2x2x2x2x2x2)
For example, if you send a value 96, it will transformed to 011000000.
Since number 0 means off and number 1 means on, in this case Q6 and Q5
will be HIGH.






Program


//Original program is http://arduino.cc/en/Tutorial/ShftOut11


//**************************************************************//
// Name : shiftOutCode, Hello World
// Author : Carlyn Maw,Tom Igoe, David A. Mellis
// Date : 25 Oct, 2006
// Modified: 23 Mar 2010
// Version : 2.0
// Notes : Code for using a 74HC595 Shift Register //
// : to count from 0 to 255
//****************************************************************


//I modified slightly


//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() {
//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}

void loop() {
//count up routine

//ground latchPin and hold low for as long as you are transmitting
digitalWrite(latchPin, LOW);

//You can change the value.

// If you use the same circuit

// TO DISPLAY   1 is 96, 2 is 220, 3 is 244, 4 is 104, 5 is 182, 6 is 62, 7 is 226, 8 is 254, 9 is 230, 0 is  250.
shiftOut(dataPin, clockPin, MSBFIRST, 254);
   

// second shift resister

//Same as the hear
shiftOut(dataPin, clockPin, MSBFIRST, 226);


//return the latch pin high to signal chip that it
//no longer needs to listen for information

digitalWrite(latchPin, HIGH);
delay(1000);

}






0 件のコメント:

コメントを投稿