I copied the code from Github and getting the attached error message:
Any guidance appreciated,
Paul

21 December 2020 9:34pm
Hey Paul,
The #include macro, #define constants and pinBatt variable declaration need to sit outside the setup function at the very top.
Declaring pinBatt outside of the setup loop, means it becomes a global variable which can be accessed by any function in the program.
So, currently what's in the first loop function, should be in the set up function, and there should be only one loop function.
So code should look like ...
#include <cmdArduino.h>
#define ADC_UNITS 1024
#define ADC_REF_VOLTAGE 3.3
#define ADC_SCALE_FACTOR 2
int pinBatt = A6;
void setup() {
// put your setup code here, to run once:
pinMode(pinBatt, INPUT);
Serial.begin(57600);
Serial.println("Module 3-3 Lab 3a: Battery Status");
cmd.add("batt", cmdBatt);
}
void loop() {
cmd.poll();
}
Here's some further info on #include libraries, #define constants and global variables if you're interested
# include
https://www.arduino.cc/reference/en/language/structure/further-syntax/include/
#define
https://www.arduino.cc/reference/en/language/structure/further-syntax/define/
Global variables and scope
https://www.arduino.cc/reference/en/language/variables/variable-scope-qualifiers/scope/
hope that helps!
Jacinta
22 December 2020 3:09am
Ah yes! Rookie mistake and soon as I saw your response I remembered the #include #define needed to be outside the setup.
Thank you!
Jacinta Plucinski
Freaklabs