Hello, I am attempting to use a nano every to run this little bit of programming written for an uno. In the IDE it compiles properly when using an uno or a standard nano, however when switching over to the board type nano every it fails to compile. I will be honest, my experience level with this is EXTREMELY limited and I was under the assumption that it would be as simple as selecting the proper board type…
I have reached out to the original author and suffice to say he is stumped the last I have heard. So, without further ado the code and attached error message. Many thanks in advance.
/*Version 20190409
ic.net: mudder
a.k.a John Sullivan
This is the original 20160813 code, modified to have the same pinout as the new "lean burn" code.
*/
int QBATTpin=6; //This is the only change between this version and 20160813
int ACTTRQpin=11;
int MOTFSApin=12;
int MOTFSBpin=13;
char frameorder[]={"ba"};
void setup() {
pinMode(MOTFSApin,OUTPUT); //clock
pinMode(MOTFSBpin,OUTPUT); //data
pinMode(QBATTpin,OUTPUT); //2kHz PWM, 10%=empty, 90%=full
pinMode(ACTTRQpin,OUTPUT); //2kHz PWM, assist>50%, regen<50%
Serial.begin(115200);
analogWrite(ACTTRQpin,127); //50% duty tells ECU "IMA not delivering torque"
analogWrite(QBATTpin,30); //12% duty tells ECU battery is nearly empty.
//Note: ECU will Autostop (i.e. stall) if QBATT indicates battery is charged
}
void loop()
{
for(int ii=0;ii<sizeof(frameorder);ii++)
{ Serial.println("");
bitbang_MOTFSB_frame(frameorder[ii]);
}
}
void bitbang_MOTFSB_frame(char nn)
{
if(nn=='a')
{
bangbit(1);
bangbit(1);
bangbit(1);
bangbit(1);
bangbit(1);
bangbit(1);
bangbit(1);
bangbit(1);
bangbit(1);
bangbit(0);
Serial.print("A");
}
else if (nn=='b')
{
bangbit(0);
bangbit(0);
bangbit(0);
bangbit(0);
bangbit(0);
bangbit(0);
bangbit(0);
bangbit(0);
bangbit(0);
bangbit(0);
Serial.print("B");
}
}
void bangbit(bool jj)
{
digitalWrite(MOTFSApin,LOW); //clock low
digitalWrite(MOTFSBpin,jj); //set data
delay(20); //20 ms
digitalWrite(MOTFSApin,HIGH); //clock high
delay(20);
}
C:\Users\Tyler\Documents\IMA_Bypass_Arduino_Code_20190416\IMA_Bypass_Arduino_Code_20190416\IMA_Bypass_20190409\IMA_Bypass_20190409.ino: In function ‘void bangbit(bool)’:
IMA_Bypass_20190409:71:30: error: cannot convert ‘bool’ to ‘PinStatus’ for argument ‘2’ to ‘void digitalWrite(pin_size_t, PinStatus)’
digitalWrite(MOTFSBpin,jj); //set data
^
exit status 1
cannot convert ‘bool’ to ‘PinStatus’ for argument ‘2’ to ‘void digitalWrite(pin_size_t, PinStatus)’
The argument to digitalWrite for the Nano Every is an enum, if you change the argument type of the function to PinStatus it should work with the 0/1 input. It has broken a lot of code making the change to the enum.
Just FYI, this issue of breakage from changing the parameter type of digitalWrite() has been reported to the Arduino developers and they have proposed a solution (but not implemented and released it so far):