Introducing: Button PID

I have been playing with this idea for a while, and was wondering what others thought.

float kPb = 1.0;
float kIb = 1.0;
float kDb =1.0;
float kLb = 50.0;

task buttonPID(){
	int error = 0;
	int pError = 0;
	int p = 0;
	int i = 0;
	int d = 0;

		error = targetValue - SensorValue[BTN1];
		p = error;
		i = abs(i + error]) < kLb ? i+ error : sgn(i + error)*kLb;
		d = error - pError;

		pError = error;
       SensorValue[BTN1] = p*kPb + i*kIb + d*kDp;


Interesting code, not exactly the “Accepted” way of doing things though. Your sig may get you kicked of the forums btw.

Thanks for the response, I figured that much, so I changed it.

It was funny (and the code still is), but not everyone shares my sense of humor.

Pegasus ? Thought you were with Chadwick. So we’re way off topic and will now end up in the “Chit Chat” forum.

Yeah Harrison, I thought you went to Chadwick :stuck_out_tongue:

@jpearman I was just trying to find another school name to replace my previous :C

@cam The school of learning is the most real school ever!

what? we learn things at my school… :stuck_out_tongue: