Background:
I'm working on a project where I intend to read the weight of an analytical lab balance by direct reading the Vacuum Florescent Display (VFD).
Currently I'm trying to figure out how to decode the info I get from the multiplexing display. I'm not terribly familiar with Arrays/Lookup Tables, Associative Arrays or Hashmaps (to my understanding Hashmaps aren't even available on the Arduino platform), and I haven't been able to find clear information on this matter.
Essentially this is what I'm trying to accomplish:
1 - Read my 8 segment input pins and concatenate them into a string.
2 - Decode that String with an Array/Lookup Table.
3 - Print that string to a 16X2 LCD.
4 - [Eventually] Control a stepper motor based on the current weight.
Currently, I'm hung up on how to decode the input.
Please see attached table (image) depicting my values.
Table: http://imgur.com/JuczQOO
NOTES:
- The eighth segment --Pin 11-- is a decimal point on the display.
- The "Pins" are the pins on the VFD.
My Test Code in Circuit I/O:
#include <LiquidCrystal.h>
long StartMillis = 3000; //Duration for Boot screen.
long CurrentMillis = 0; //Current Time on Clock.
String Weight = ""; //Starting Weight Should be nil.
String Startup = "Startup Text!"; //Startup Text.
String CatStr = "empty"; //Concatenation of inputs
String STRA = "0";// In the future these will become defined input pins as opposed to strings.
String STRB = "1";// In the future these will become defined input pins as opposed to strings.
String STRC = "2";// In the future these will become defined input pins as opposed to strings.
String STRD = "3";// In the future these will become defined input pins as opposed to strings.
String STRE = "4";// In the future these will become defined input pins as opposed to strings.
String STRF = "5";// In the future these will become defined input pins as opposed to strings.
String STRG = "6";// In the future these will become defined input pins as opposed to strings.
String STRH = "7";// In the future these will become defined input pins as opposed to strings.
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//Lookup Table:
/*
T B
0,11101110
1,00100100
2,10111010
3,10110110
4,01110100
5,11010110
6,11011110
7,10100100
8,11111110
9,00000000
*/
//End Lookup Table
void setup()
{
lcd.begin(16, 2);
lcd.clear();
}
void loop()
{
unsigned long CurrentMillis = millis ();
String CatStr = "";
CatStr = (STRA)+(STRB)+(STRC)+(STRD)+(STRE)+(STRF)+(STRG)+(STRH);
//Weight = CatStr [decoded]
if (CurrentMillis < StartMillis)
{
lcd.print(Startup);
delay(2000);
lcd.clear();
}
else
{
lcd.print(CatStr); //later, this will be "Weight" not "CatStr."
delay(3000);
lcd.clear();
lcd.print("Yay!");
delay(1000);
lcd.clear();
}
}
Thanks in advance for all the help!