Up Key input does not work

arduino uno up Key input does not work,double setpoint = 76.12; The decimal point cannot be added or subtracted

#define DIN 8
#define CLK 3
#define LOAD 4
#define KEY_Position A1
#define KEY_UP A3
#define KEY_DW A2

#include "LedControl.h"
#define DIN 8 //DIN 12
#define CLK 3 //CLK 10
#define LOAD 4 //LOAD/CS 11

LedControl lc = LedControl(DIN, CLK, LOAD, 1);

long sht_temp;
long a, x, y, z, h;
double setpoint = 76.12;
long digito1, digito2, digito3, digito4, digito5, digito6, digito7, digito8;
int key_mode = 3;
long set_Setpoint;

void max7219_view()
{
sht_temp = setpoint * 100;
printC(sht_temp);
}

void MAX7219_Char()
{
delay(130);
lc.setChar(0, key_mode, ' ', 0); //void clearDisplay ( int * addr )
delay(130);
}

void setup()
{ Serial.begin(9600);
pinMode(KEY_Position, INPUT);
pinMode(KEY_UP, INPUT);
pinMode(KEY_DW, INPUT);

digitalWrite(KEY_Position, HIGH);
digitalWrite(KEY_UP, HIGH);
digitalWrite(KEY_DW, HIGH);

lc.shutdown(0, false);
lc.setIntensity(0, 7);
lc.clearDisplay(0);

delay(500);
}

void loop()
{ if (digitalRead(KEY_Position) == LOW)
{
key_mode ++;
if (key_mode >= 8)
{
key_mode = 3;
}
}

max7219_view();
set_Setpoint = setpoint * 100;

h = (set_Setpoint % 10) ;
z = (set_Setpoint / 10 ) % 10 ;
y = (set_Setpoint / 100 ) % 10 ;
x = (set_Setpoint / 1000 ) % 10 ;
a = (set_Setpoint / 10000 ) % 10 ;

if (!digitalRead(KEY_UP) and key_mode == 3) h += 1;
else if (!digitalRead(KEY_DW) and key_mode == 3) h -= 1;
else if (!digitalRead(KEY_UP) and key_mode == 4) z += 1;
else if (!digitalRead(KEY_DW) and key_mode == 4) z -= 1;
else if (!digitalRead(KEY_UP) and key_mode == 5) y += 1;
else if (!digitalRead(KEY_DW) and key_mode == 5) y -= 1;
else if (!digitalRead(KEY_UP) and key_mode == 6) x += 1;
else if (!digitalRead(KEY_DW) and key_mode == 6) x -= 1;
else if (!digitalRead(KEY_UP) and key_mode == 7) a += 1;
else if (!digitalRead(KEY_DW) and key_mode == 7) a -= 1;
if (h > 9) {
h = 0;
}
if (h < 0) {
h = 0;
}
if (z > 9) {
z = 0;
}
if (z < 0) {
z = 0;
}
if (y > 9) {
y = 0;
}
if (y < 0) {
y = 0;
}
if (x > 9) {
x = 0;
}
if (x < 0) {
x = 0;
}
if (a > 9) {
x = 0;
}
if (a < 0) {
x = 0;
}

long ttt = (a * 10000) + (x * 1000) + (y * 100) + (z * 10) + h;

setpoint = ttt ;
setpoint = setpoint / 100 ;

Serial.println(setpoint);
MAX7219_Char();
}
void printC( long sht_temp)
{

digito4 = (sht_temp % 10) ;
digito5 = (sht_temp / 10 ) % 10 ;
digito6 = (sht_temp / 100 ) % 10 ;
digito7 = (sht_temp / 1000 ) % 10 ;
digito8 = (sht_temp / 10000 ) % 10 ;
bit_dig();
}
void bit_dig()
{
lc.setDigit ( 0 , 7 , (byte) digito8, false);
lc.setDigit ( 0 , 6 , (byte) digito7, false);
lc.setDigit ( 0 , 5 , (byte) digito6, true);
lc.setDigit ( 0 , 4 , (byte) digito5, false);
lc.setDigit ( 0 , 3 , (byte) digito4, false);
}

proteus

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Before all that, you wrote a simple test sketch that just checked that your wiring was correct, and you could read the switches, and print some simple debug messages - does that still work?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.