Any feedback and advise for this so far please? It doesnt compile currently as it doesnt like my bcdtodec call.
-
finds which analog input is active (1-8)
-
calculates the what the voltage level is (1-8)
-
converts the results for both to binary
-
combines them into a single binary number
-
converts back to decimal
-
not completed yet, but it will then compare the possible 64 variations and some more mathematics, then display the result on an LCD.
int i; // large plate
int x;
int platelet; // small platelet
int plate; // large plate
int volts;
int w;
byte calctotal;
void setup()
{
}
void loop()
{
// locates which of the 8 input plates is being used
for (i = 19; i < 27; ++i) {
if ((volts = analogRead(i)) > 100)
voltage(volts);
int decToBcd(byte i);
int decToBcd(byte w);
int calc(byte w, byte i);
byte bcdtodec(byte calctotal};
}
int voltage(int x)
{
float volts = x * (5.0 /1023.0);
// locates which of the 8 voltages is being received
if (volts < 0.6535)
w = (1);
else if (volts < 1.2595)
w = 2;
else if (volts < 1.874)
w = (3);
else if (volts < 2.4915)
w = (4);
else if (volts < 3.1105)
w = (5);
else if (volts < 3.7305)
w = (6);
else if (volts < 4.3515)
w = (7);
else
w = (8);
return (int)volts;
}
byte decToBcd(byte val) // Convert voltage number and plate number to binar
{
return ( (val/10*16) + (val%10) );
}
int calc(byte y, byte z)
{
uint8_t lower_part = y;
uint8_t upper_part = z;
uint8_t result = 0; // accumulator to build result
result |= (lower_part & 0b00001111); // i
result |= ((upper_part & 0x00001111) << 4); //
byte calctotal = result;
return result;
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}
Project.ino: In function 'void loop()':
Project:23: error: expected ',' or '...' before '}' token
Project:23: error: expected `)' before '}' token
Project:23: error: expected initializer before '}' token