Big time fan of the arduino here, but just starting out. Long time lurker on these boards, but now I want to join in on all the fun here. ![]()
Ok background:
I recently purchased a 12" Milone eTape for reading the level of liquid in a container. Now I would like to interface that using two shift registers (74hc595n) two one digit 7 segment displays (common cathode).
I have the code for taking the measurements from the e-tape and converting to % full all working printing out to serial. now I am trying to send those two digits (since I have it set to never >= 100%) to the two displays, and I can't seem to wrap my brain around using the shift register system. Percent comes out as an int btw.
I wired and ran the examples on
Currently it's cycling through example 3 flawlessly. Using the 7 seg displays instead of 8 LEDs.
Now I believe that I should use something like the coding used on
Located in the comments (comment 3 from top I believe)
Because they implement a very clever way of separating the digits translating that to the binary that the 7segment displays and sending them through the register. But then when I tried to implement the code in the last link I think I realized that I'm out of my depth and decided to come here for help.
All I wanted to do with my 'work in progress' code was to show "percentFull" on the two displays so I could then rout what's being printed in my working code to be printed on the displays.
Sorry for the lack of comments, been frustratingly trying multiple different things.
Too many frustrating things today, please somebody give me direction or help!
Working eTape code
#define SERIESRESISTOR 560
#define SENSORPIN A0
#define sensorMax 2398
#define sensorMin 350
void setup(void)
{
Serial.begin(9600);
analogReference(EXTERNAL);
}
void loop(void)
{
float sensorValue = analogRead(A0);
Serial.print(sensorValue);
Serial.print(" ");
sensorValue = (1024 / sensorValue) - 1;
sensorValue = SERIESRESISTOR / sensorValue;
Serial.print(sensorValue);
Serial.print(" ");
float deptha = sensorMax - sensorValue;
float depthb = sensorMax - sensorMin;
int percentFull = (deptha / depthb) * 100;
Serial.print(percentFull);
Serial.println("%");
delay(1000);
}
WORKINPROGRESS
const int clockPin = 12;
const int latchPin = 11;
const int dataPin = 8;
const byte digit[10] =
{
B00111111,
B00000110,
B01011011,
B01001111,
B01100110,
B01101101,
B01111101,
B00000111,
B01111111,
B01101111
};
int digitBuffer[2] = {0};
int digitScan = 0;
float percentFull;
void setup()
{
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void updateDisp()
{
/*
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, B00000000);
digitalWrite(latchPin, HIGH);
delayMicroseconds(2);
*/
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, digit[digitBuffer[digitScan]]);
shiftOut(dataPin, clockPin, MSBFIRST, digit[digitBuffer[digitScan]]);
digitalWrite(latchPin, HIGH);
digitScan++;
if(digitScan>2) digitScan=0;
}
void loop()
{
int percentFull = 25;
digitBuffer[1] = int(percentFull)/10;
digitBuffer[0] = int(percentFull)%10;
delay(4);
updateDisp();
}



