Help for checking if PID code
KP, KI and KD are usually fixed and not manipulated based on the error as you are doing. Instead try and get the controller working as P-only.
Try reducing it to this and get P-only control working properly: -
piderror = setpoint - inputvalue;
proportional = kp * piderror; 
pidvalue = proportional + integral;
if (pidvalue &lt;= 0) {
  pidvalue = 0;
}
if (pidvalue &gt; 255) {
  pidvalue = 255;
}
analogWrite(pin, pidvalue);

Start with a much gentler KP - maybe 1 or 2, try it out and report back. Plot a graph if you can and edit it into your question. We'll proceed from there.