Hi there,
I posted my problem already in the german part of the forum, but until now nobody could help me.
I connected two 7-Segment LED-Displays via two 74HTC595 shift-registers with my arduino, which shall change from 01-40 when I turn around a rotary encoder. (This is at least the step goal - later the final programm shall control the PLL of a radio).
This is the code I used:
#include <PinChangeInt.h> // necessary otherwise we get undefined reference errors.
#include <AdaEncoder.h>
#define a_PINA 5
#define a_PINB 7
const int latch = 8;
const int data = 11;
const int clock = 12;
int kanaele_einer[] = {6,91,79,102,109,125,7,127,103,63,6,91,79,102,109,125,7,127,103,63,6,91,79,102,109,125,7,127,103,63,6,91,79,102,109,125,7,127,103,63}; // right segment, one-spot?
int kanaele_zehner[] = {63,63,63,63,63,63,63,63,63,6,6,6,6,6,6,6,6,6,6,91,91,91,91,91,91,91,91,91,91,79,79,79,79,79,79,79,79,79,79,102}; // left segment, ten-spot?
int x = 1;
int8_t clicks=0;
char id=0;
void setup()
{
AdaEncoder::addEncoder('a', a_PINA, a_PINB);
pinMode(clock, OUTPUT); // make the clock pin an output
pinMode(data, OUTPUT); // make the data pin an output
pinMode(latch, OUTPUT); // make the latch pin an output
}
void loop()
{
encoder *thisEncoder;
thisEncoder=AdaEncoder::genie(&clicks, &id);
if (thisEncoder != NULL) {
thisEncoder=AdaEncoder::getFirstEncoder();
if (clicks > 0 ) {
x++};
if (x==41) {
x=1}
if (clicks < 0) {
x--};
if (x==0) {
x=40};
}
// Anzeigenausgabe
digitalWrite(latch, 0);
shiftOut(data, clock, MSBFIRST, kanaele_einer[x]);
shiftOut(data, clock, MSBFIRST, kanaele_zehner[x]);
digitalWrite(latch, 1);
}
My problem is now that the left segment (which shows the tenner) works perfectly (it shows 0-4), however on the right display all segments seem to shine all at once (however in different grades of brightness). There is of a course a slight change if I turn the encoder, but the right segments stay unreadable.
It is not a mistake in the wiring - if I call the 40 different variables up with a for-loop, it works spendlidly. Just how the rotary encoder code works without a problem, if the result is sent via usb to the arduino-gui?
Can anybody help me?