John How do I call the function to return the value so I could print it
If I use DIGIT1 = getDigit(); I get too few arguments to function 'const char getDigit(byte)'
It's not like calling a function I guess but tried to read up on it but they are just all normal functions calls, This bit is new to me
Code attached
byte DMM_ARRAY[14]; // Where to store the Bytes read
int ledPin = 13; // Set the pin to digital I/O
int index = 0;
byte c;
byte TEMP1;
byte TEMP2;
byte TEMP3;
byte TEMP4;
byte DIGIT1;
byte LOOKDOWN1[7];
byte LOOKDOWN2[7];
byte LOOKDOWN3[7];
byte LOOKDOWN4[7];
boolean STORED1 ;
boolean STORED2 = 1;
boolean STORED3 = 0;
boolean STORED4 = 0;
int F_SELECT ;
char temp2;
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x03f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
const byte Segments[] = {0x7D, 0x05, 0x5B, 0x1F, 0x27, 0x3E, 0x7E, 0x15, 0x7F, 0x3F, 0x00, 0x68};
const char Digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ', 'L'};
void setup()
{
lcd.begin (20, 4); // for 16 x 2 LCD module
lcd.setBacklight(HIGH);
pinMode(ledPin, OUTPUT);
Serial.begin(2400);
}
void loop() {
Get_data();
//print the hex bytes to the display
lcd.setCursor(0, 0);
lcd.print(DMM_ARRAY[0], HEX);
lcd.print(",");
lcd.print(DMM_ARRAY[1], HEX);
lcd.print(",");
lcd.print(DMM_ARRAY[2], HEX);
lcd.print(",");
lcd.print(DMM_ARRAY[3], HEX);
lcd.print(",");
lcd.print(DMM_ARRAY[4], HEX);
lcd.print(",");
lcd.print(DMM_ARRAY[5], HEX);
lcd.print(",");
lcd.print(DMM_ARRAY[6], HEX);
lcd.setCursor(0, 1);
lcd.print(DMM_ARRAY[7], HEX);
lcd.print(",");
lcd.print(DMM_ARRAY[8], HEX);
lcd.print(",");
lcd.print(DMM_ARRAY[9], HEX);
lcd.print(",");
lcd.print(DMM_ARRAY[10], HEX);
lcd.print(",");
lcd.print(DMM_ARRAY[11], HEX);
lcd.print(",");
lcd.print(DMM_ARRAY[12], HEX);
lcd.print(",");
lcd.print(DMM_ARRAY[13], HEX);
//'BYTES 1&2 FOR THE FIRST DIGIT AND PRINTS THE NEGATIVE SIGN
for (int LOOP1 = 1; LOOP1 <= 7; LOOP1 += 2) {
TEMP1 = (DMM_ARRAY[1] << 4) | DMM_ARRAY[2] & 0x0F;
if (TEMP1 & 0x80) {
lcd.setCursor(3, 3);
lcd.print("-"); //print - just to show it working
TEMP1 &= 0x7F;;
} else {
lcd.setCursor(3, 3);
lcd.print("+"); //print + just to show it working
}
for (int i = 0; i < sizeof LOOKDOWN1; i++) {
if (LOOKDOWN1[i] == TEMP1) {
TEMP1 = i;
//temp2[] ={ 0x7D, 0x05, 0x5B, 0x1F, 0x27, 0x3E, 0x7E, 0x15, 0x7F, 0x3F, 0 };
break;
}
}
}
//'BYTES 3&4 FOR THE FIRST DIGIT AND PRINTS THE NEGATIVE SIGN
for (int LOOP2 = 1; LOOP2 <= 7; LOOP2 += 2) {
TEMP2 = (DMM_ARRAY[3] << 4) | DMM_ARRAY[4] & 0x0F;
F_SELECT = 0;
TEMP2 &= 0x7F;
for (int l2 = 0; l2 < sizeof LOOKDOWN2; l2++) {
if (LOOKDOWN2[l2] == TEMP2) {
getDigit();
//temp2[] ={ 0x7D, 0x05, 0x5B, 0x1F, 0x27, 0x3E, 0x7E, 0x15, 0x7F, 0x3F, 0 };
break;
}
}
}
//'BYTES 5&6 FOR THE FIRST DIGIT AND PRINTS THE NEGATIVE SIGN
for (int LOOP3 = 1; LOOP3 <= 7; LOOP3 += 2) {
TEMP3 = (DMM_ARRAY[5] << 4) | DMM_ARRAY[6] & 0x0F;
F_SELECT = 1;
TEMP3 &= 0x7F;
/* for (int l3 = 0; l3 < sizeof LOOKDOWN3; l3++) {
if (LOOKDOWN3[l3] == TEMP3) {
//temp2[] ={ 0x7D, 0x05, 0x5B, 0x1F, 0x27, 0x3E, 0x7E, 0x15, 0x7F, 0x3F, 0 };
break;
}
}
*/
}
//'BYTES 7&8 FOR THE FIRST DIGIT AND PRINTS THE NEGATIVE SIGN
for (int LOOP4 = 1; LOOP4 <= 7; LOOP4 += 2) {
TEMP4 = (DMM_ARRAY[7] << 4) | DMM_ARRAY[8] & 0x0F;
F_SELECT = 2;
TEMP4 &= 0x7F;
/* for (int l4 = 0; l4 < sizeof LOOKDOWN4; l4++) {
if (LOOKDOWN4[l4] == TEMP4) {
//temp2[] ={ 0x7D, 0x05, 0x5B, 0x1F, 0x27, 0x3E, 0x7E, 0x15, 0x7F, 0x3F, 0 };
break;
}
}
*/
}
switch (F_SELECT) {
case 0:
lcd.setCursor(10, 3);
lcd.print("CASE 1");
break;
case 1:
lcd.setCursor(10, 3);
lcd.print("CASE 2");
break;
case 2:
lcd.setCursor(10, 3);
lcd.print("CASE 3");
break;
}
lcd.setCursor(0, 2);
lcd.print(TEMP2);
lcd.print(",");
lcd.print(TEMP3);
lcd.print(",");
lcd.print("f");
}
void Get_data() {
while (Serial.available() < 14) {} // Wait 'till there are 14 Bytes waiting
for (int n = 0; n < 14; n++)
DMM_ARRAY[n] = Serial.read(); // Then: Get them.
}
const char getDigit(const byte segments) {
for (int i = 0; i < sizeof Segments / sizeof Segments[0]; i++) {
if (Segments[i] == segments)
return Digits[i];
}
return '?';
}
Thanks
Steve