A simple and effective method is using shift registers. Shift register IC used for our purpose is 74HC595. This tutorial is to make you an expert in this project quickly. So the timing diagram is not going to explain in this blog. If you want to read more about 74595, get the PDF from here. All other details such as voltage rating, limiting values, recommended operating conditions and timing diagram is clearly explained in the datasheet.
Now upload the following program to your arduino board.
//Pin connected to ST_CP of 74595 int latchPin = 12; //Pin connected to SH_CP of 74595 int clockPin = 13; ////Pin connected to DS of 74595 int dataPin = 11; void setup() { //set pins to output so you can control the shift register pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); } void loop() {
int ShiftOut_value = 1;
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, ShiftOut_value);
//take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); }
Output:
Q0 will turn on, all others will turn off.
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
1 0 0 0 0 0 0 0
Program to shift out number 2 to 74595 in MSBFIRST order
Upload the following program to your arduino board.
//Pin connected to ST_CP of 74595 int latchPin = 12; //Pin connected to SH_CP of 74595 int clockPin = 13; ////Pin connected to DS of 74595 int dataPin = 11; void setup() { //set pins to output so you can control the shift register pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); } void loop() {
int ShiftOut_value = 2;
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, ShiftOut_value);
//take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); }
Output:
Q1 will turn on, all others will turn off.
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
0 1 0 0 0 0 0 0
Program to shift out number 3 to 74595 in MSBFIRST order
Now upload the following program to your arduino board.
//Pin connected to ST_CP of 74595 int latchPin = 12; //Pin connected to SH_CP of 74595 int clockPin = 13; ////Pin connected to DS of 74595 int dataPin = 11; void setup() { //set pins to output so you can control the shift register pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); } void loop() {
int ShiftOut_value = 3;
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, ShiftOut_value);
//take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); }
Output:
Q0 and Q1 will turn on, all others will turn off.
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
1 1 0 0 0 0 0 0
Read the remaining in next page.
Read Next Page >> |
You can choose between active and passive buzzer? Here https://nerdytechy.com/active-vs-passive-buzzer/ you can understand differences!
Reply DeleteHere you can find the best bluetooth modules for Arduino
Reply Delete