Hello everyone I'm new here and need some help with the project steering .I would like to do 16pcs LEDs using 2 pieces 74HC595 but after installing the program to the CPU instead of 16 bit 8 mustache me a bit.
here is the code for 8-bit display ICs both the same.
latch int constPin = 5; // Pin connected to Pin 12 of 74HC595 (Latch)
const int dataPin = 6; // Pin connected to Pin 14 of 74HC595 (Date)
const int clockPin = 7; // Pin connected to Pin 11 of 74HC595 (Clock)
int counter = 0; // Initialise counter as a zero
potReading int = 0;
const byte numbers [20] =
{0xff,0x7f,0xbf,0xdf,0x1f,0x6f,0x4f,0xf7,0x57,0xa7,0x7b,0x6b,0xd3,0xbd,0xad,0x35,0x45,0xe9,0x51,0x3e};
void setup ()
{
pinMode (latchPin, OUTPUT);
pinMode (clockPin, OUTPUT);
pinMode (dataPin, OUTPUT);
}
void loop ()
{
potReading = analogRead (A0);
potReading = map (potReading, 0, 1023, 0, 20);
{
if (potReading> 20)
potReading -;
show (numbers [potReading]);
}
{
if (potReading <0)
potReading ++;
show (numbers [potReading]);
}
}
void show (byte number)
{
for (int j = 0; j <= 7; j ++)
{
towrite byte = number & (B10000000 >> j);
if (! towrite) {
continue;
}
shiftIt (towrite);
}
}
void shiftIt (byte data)
{
digitalWrite (latchPin, LOW);
for (int k = 0; k <= 7; k ++)
{
digitalWrite (clockPin, LOW);
if (date & (1 << k))
{
digitalWrite (dataPin, HIGH);
}
else
{
digitalWrite (dataPin, LOW);
}
digitalWrite (clockPin, HIGH);
}
digitalWrite (clockPin, LOW);
digitalWrite (latchPin, HIGH);
}
and so no longer works as error
latch int constPin = 5; // Pin connected to Pin 12 of 74HC595 (Latch)
const int dataPin = 6; // Pin connected to Pin 14 of 74HC595 (Date)
const int clockPin = 7; // Pin connected to Pin 11 of 74HC595 (Clock)
int counter = 0; // Initialise counter as a zero
potReading int = 0;
const byte numbers [20] =
{0xfff0,0x7ff0,0xbff0,0xdff0,0x1ff0,0x6ff0,0x4ff0,0xf7f0,0x57f0,0xa7f0,0x7bf0,0x6bf0,0xd3f0,0xbdf0,0xadf0,0x35f0,0x45f0,0xe9f0,0x51f0,0x3ef0,
};
void setup ()
{
pinMode (latchPin, OUTPUT);
pinMode (clockPin, OUTPUT);
pinMode (dataPin, OUTPUT);
}
void loop ()
{
potReading = analogRead (A0);
potReading = map (potReading, 0, 1023, 0, 20);
{
if (potReading> 20)
potReading -;
show (numbers [potReading]);
}
{
if (potReading <0)
potReading ++;
show (numbers [potReading]);
}
}
void show (byte number)
{
for (int j = 0; j <= 7; j ++)
{
towrite byte = number & (B10000000 >> j);
if (! towrite) {
continue;
}
shiftIt (towrite);
}
}
void shiftIt (byte data)
{
digitalWrite (latchPin, LOW);
for (int k = 0; k <= 7; k ++)
{
digitalWrite (clockPin, LOW);
if (date & (1 << k))
{
digitalWrite (dataPin, HIGH);
}
else
{
digitalWrite (dataPin, LOW);
}
digitalWrite (clockPin, HIGH);
}
digitalWrite (clockPin, LOW);
digitalWrite (latchPin, HIGH);
}