Bug fixing Arduino Code

This commit is contained in:
Alexander Richter 2022-11-26 01:16:53 +01:00
parent 9ae56ab73c
commit c3005f77ab

View File

@ -62,7 +62,7 @@
#define PWMOUTPUTS #define PWMOUTPUTS
#ifdef PWMOUTPUTS #ifdef PWMOUTPUTS
const int PwmOutputs = 2; //number of outputs const int PwmOutputs = 2; //number of outputs
int PwmOutPinmap[] = {13,11}; int PwmOutPinmap[] = {12,11};
#endif #endif
#define AINPUTS #define AINPUTS
@ -262,30 +262,22 @@ void flushSerial(){
} }
void writeOutputs(int Pin, int Stat){ void writeOutputs(int Pin, int Stat){
for(int x = 0; x<Outputs;x++){ digitalWrite(Pin, Stat);
if(OutPinmap[x]==Pin){
digitalWrite(OutPinmap[x], Stat);
}
}
} }
void writePwmOutputs(int Pin, int Stat){ void writePwmOutputs(int Pin, int Stat){
for(int x = 0; x<PwmOutputs;x++){ analogWrite(Pin, Stat);
if(PwmOutPinmap[x]==Pin){
analogWrite(PwmOutPinmap[x], Stat);
}
}
} }
int readLPoti(){ int readLPoti(){
for(int i= 0;i<LPotis; i++){ for(int i= 0;i<LPotis; i++){
int State = analogRead(LPotiPins[i][0])+margin; int var = analogRead(LPotiPins[i][0])+margin;
Lpoti[i] = 1024/(LPotiPins[i][1]-1); int pos = 1024/(LPotiPins[i][1]-1);
State = State/(LPotiPins[i][1]-1); var = var/pos;
if(oldLpoti[i]!= State){ if(oldLpoti[i]!= var){
oldLpoti[i] = State; oldLpoti[i] = var;
sendData('L', LPotiPins[i][0],oldLpoti[i]); sendData('L', LPotiPins[i][0],oldLpoti[i]);
} }
} }