Hello to everyone I keep getting this error >:( >:( >:( , I followed the guide and i found that my code should be correct. Do you have any pointers?
Although my function type is int it keeps saying that i use void.
I try to read the analog input from a current sensor this is acs712.h
int current(int choose);
int current(int choose){
int mVperAmp = 0; // use 185 for 5A Module, 100 for 20A Module and 66 for 30A Module
int RawValue= 0;
int ACSoffset = 1658;
double Voltage = 0;
int Amps;
if (choose == 16){
mVperAmp = 100; // use 100 for 20A Module and 66 for 30A Module
RawValue = analogRead(current16A);
Voltage = (RawValue / 4096.0) * 3300; // Gets you mV
Amps = ((Voltage - ACSoffset) / mVperAmp);
return Amps;
}
else if (choose == 5){
mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module
RawValue = analogRead(current5A);
Voltage = (RawValue / 4096.0) * 3300; // Gets you mV
Amps = ((Voltage - ACSoffset) / mVperAmp);
return Amps;
}
}
while from the main page i call the result like this
#include "pinout.h"
#include "acs712.h"
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop(){
Amps = current(5);
Serial.print(Amps);
}
the error i get on the compiler
sketch\acs712.h: In function 'void current(int)':
sketch\acs712.h:16:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
return Amps;
^
sketch\acs712.h:23:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
return Amps;
^
exit status 1
**keep in mind i use an stm32 "blue pill" board with arduino bootloader and using arduino IDE