So I have been programming my board to receive voltage inputs from the fuel cells and to short fuel cells but so far I’ve been having problems compiling the code
i keep getting this error message
Shorting_algorithm:20:29: error: expected unqualified-id before ‘[’ token
struct short_AnalogReading[6]{
^
Shorting_algorithm:27:2: error: ‘short_analogReading’ does not name a type; did you mean ‘short_AnalogReading’?
}short_analogReading;
^~~~~~~~~~~~~~~~~~~
short_AnalogReading
Shorting_algorithm:28:2: error: expected ‘;’ after class definition
}
^
;
Shorting_algorithm:34:4: error: a function-definition is not allowed here before ‘{’ token
{
^
Shorting_algorithm:92:5: error: a function-definition is not allowed here before ‘{’ token
{
^
Shorting_algorithm:150:1: error: expected ‘}’ at end of input
}
^
exit status 1
expected unqualified-id before ‘[’ token
and this is the program
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
}
class variables {
struct short_AnalogReading[6]{
double val0;
double val1;
double val2;
double val3;
double val4;
double val5;
}short_analogReading;
}
void loop() {
int shorting()
{
static int MuxPointer = 0;
if (MuxPointer > 5) { // check if Mux Pointer is within bounds
MuxPointer = 0; // reset to zero if not
}
switch (MuxPointer) { // lookup to assign PORT bits to Mux number
case 0:
val0 = analogRead(A0); // read the input pin
Serial.println(“Module 1 short begin”);
while(unsigned int i=0; i<100; i++)
{
digitalWrite(2, HIGH);
Serial.println(".\r"); //after 100ms
}
digitalWrite(2,LOW);
//get the reading for voltage (pulse module short voltage)
break;
case 1:
val1 = analogRead(A1); // read the input pin
Serial.println(“Module 2 shorted”);
digitalWrite(3, HIGH);
break;
case 2:
val2 = analogRead(A2); // read the input pin
Serial.println(“Module 3 shorted”);
digitalWrite(4, HIGH);
delay(100);
break;
case 3:
val3 = analogRead(A3); // read the input pin
Serial.println(“Module 4 shorted”);
digitalWrite(5, HIGH);
delay(100);
break;
case 4:
val4 = analogRead(A4); // read the input pin
Serial.println(“Module 4 shorted”);
digitalWrite(6, HIGH);
delay(100);
break;
case 5:
val5 = analogRead(A5); // read the input pin
Serial.println(“Module 4 shorted”);
digitalWrite(7, HIGH);
delay(100);
break;
delay(1000); // Allow ADC to settle
MuxPointer++;
}
}
int Readings()
{
struct AnalogReading[6]{
double cellv0;
double cellv1;
double cellv2;
double cellv3;
double cellv4;
double cellv5;
}analogReading;
static int modulePointer = 0;
if (modulePointer > 5) { // check if Mux Pointer is within bounds
modulePointer = 0; // reset to zero if not
}
switch (modulePointer) { // lookup to assign PORT bits to Mux number
case 0:
cellv0 = analogRead(A0); // read the input pin
Serial.println(“Module 1 voltage”);
Serial.print(cellv0);
break;
case 1:
cellv1 = analogRead(A1); // read the input pin
Serial.println(“Module 2 voltage”);
Serial.print(cellv1);
break;
case 2:
cellv2 = analogRead(A2); // read the input pin
Serial.println(“Module 3 voltage”);
Serial.print(cellv2);
break;
case 3:
cellv3 = analogRead(A3); // read the input pin
Serial.println(“Module 4 voltage”);
Serial.print(cellv3);
break;
case 4:
cellv4 = analogRead(A4); // read the input pin
Serial.println(“Module 5 voltage”);
Serial.print(cellv4);
break;
case 5:
cellv5 = analogRead(A5); // read the input pin
Serial.println(“Module 6 voltage”);
Serial.print(cellv5);
break;
delay(1000); // Allow ADC to settle
modulePointer++;
}
}