code upload successfully but whenever i push a button it doesnt work

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
#include <stdlib.h>

int voltagePin = A3;
int currentPin = A0;
int pwmCurrentPin = 10;
int pwmVoltagePin = 9;
int potPin = A1;
int key1Pin = 8;
int key2Pin = 12;
int key3Pin = 11;
int prevk1=1;
int prevk2=1;
int prevk3=1;
int currk1=1;
int currk2=1;
int currk3=1;
float voltageRef = 0;
float currentRef = 0;

float readVoltage()
{
float total=0;
for(int n=0;n<100;n++)
{
float temp = (float) analogRead(voltagePin);
temp = 1.1 * temp/1024 * 30;
total = total + temp;
delay(1);
}
return total/100;
}

float readCurrent()
{
float total=0;
for(int n=0;n<100;n++)
{
float temp = (float) analogRead(currentPin);
temp = temp/1024 * 5;
temp = (temp-2.51)250.185;
total = total + temp;
delay(1);
}
return total/100;
}

float readPot()
{
float temp = (float) analogRead(potPin);
temp = temp/1024;
return temp;
}

void showCurrentSet(float value)
{
char txt[6];
dtostrf(value,4,1,txt);
lcd.setCursor(11,0);
lcd.print(txt);
}

void showVoltageSet(float value)
{
char txt[6];
dtostrf(value,5,1,txt);
lcd.setCursor(4,0);
lcd.print(txt);
}

void showVoltageAct(float value)
{
char txt[6];
dtostrf(value,5,1,txt);
lcd.setCursor(4,1);
lcd.print(txt);
}

void showCurrentAct(float value)
{
char txt[6];
dtostrf(value,4,1,txt);
lcd.setCursor(11,1);
lcd.print(txt);
}

void setup()
{
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("ARDX VarPwrS 30V10A+");
lcd.setCursor(6,1);
lcd.print("Ver.001A");
lcd.setCursor(2,2);
lcd.print("SET:00.00V 0.00A");
lcd.setCursor(2,3);
lcd.print("ACT:00.00V 0.00A");
pinMode(key1Pin, INPUT_PULLUP);
pinMode(key2Pin, INPUT_PULLUP);
pinMode(key3Pin, INPUT_PULLUP);
pinMode(pwmVoltagePin, OUTPUT);
analogWrite(pwmVoltagePin, 0);
pinMode(pwmCurrentPin, OUTPUT);
currentRef = 0.5;
analogWrite(pwmCurrentPin,128 + (currentRef*12.7));
}

void loop()
{
int tempk1 = digitalRead(key1Pin);
int tempk2 = digitalRead(key2Pin);
int tempk3 = digitalRead(key3Pin);
int count = 0;
while (count < 10)
{
currk1 = digitalRead(key1Pin);
currk2 = digitalRead(key2Pin);
currk3 = digitalRead(key3Pin);
if(tempk1 = currk1)
{
tempk1 = currk1;
count = 0;
}
if(tempk2 = currk2)
{
tempk2 = currk2;
count = 0;
}
if(tempk3 = currk3)
{
tempk3 = currk3;
count = 0;
}
count++;
}

if((currk1==0)&&(prevk1==1))
{
currentRef = currentRef + 0.5;
if(currentRef>3) currentRef=3;
showCurrentSet(currentRef);
analogWrite(pwmCurrentPin,128 + (currentRef*11));
}

if((currk2==0)&&(prevk2==1))
{
currentRef = currentRef - 0.5;
if(currentRef<0.5) currentRef=0.5;
showCurrentSet(currentRef);
analogWrite(pwmCurrentPin,128 + (currentRef*12.7));
}

if((currk3==0)&&(prevk3==1))
{
}

prevk1=currk1;
prevk2=currk2;
prevk3=currk3;

showVoltageAct(readVoltage());
showCurrentAct(readCurrent());
showCurrentSet(currentRef);
showVoltageSet(readPot()30);
analogWrite(pwmVoltagePin, 0.91
readPot()*255);
}

Please read How to use this forum - please read. - Installation & Troubleshooting - Arduino Forum, specifically point #7 about posting code.

Next edit your post and add the code tags.

Next describe what "it does not work" means. What do you expect it to do, what does it do.

    if (tempk1 = currk1)

'=' is to assign a value; '==' is to compare two values.

Check all your conditions.

im sorry if i post it here...really needs some help here...the code uploads to my arduino and it display what needs to display on lcd...the only the original code uses standard lcd library..i changed it to lcd i2c...my problem is the buttons and potentimeter desnt work it should change the display and buttons should change a set value...im definitely sure that my wiring is correct...sorry for my bad english ..

If the code worked with another display, you made other changes than the ones that were needed for the display.

I showed one bug in reply #2 and I'm sure there are more mistakes like that.

Don't be sorry for asking questions. But please honour requests from people that try to help; so please read the link that I gave and edit your original post.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile: