Running two different programs on arduino uno

Hi, im new to arduino. Im doing a project where im trying to use push buttons to switch between two different programs. So far i’ve not suceeded. Here is my code:

const int pb1=0, pb2=1, pb3=14, pb4=15, pb5=16, pb6=17, pb7=13, encswt=19, relay= 18;
int i=0, j=0, k=0, l=0, t=0;
int v1=0, v2=0, v3=0, v4=0, v5=0, v6=0, v7=0, enV=0;
int pbCode1=0, pbCode2=0, pbInc100=0, pbInc10=0, pbInc1=0, pbStart=0, pbReset=0, encSwt=0;
float encoder=0;

void setup()
{
DDRD=0xff;
DDRB=0xff;
PORTD=0x00;
PORTB=0x00;
pinMode(pb1, INPUT);
pinMode(pb2, INPUT);
pinMode(pb3, INPUT);
pinMode(pb4, INPUT);
pinMode(pb5, INPUT);
pinMode(pb6, INPUT);
pinMode(pb7, INPUT);
pinMode(encswt, INPUT);
pinMode(relay, OUTPUT);
}

void loop ()
{
pbCode1= digitalRead(pb1);
pbCode2= digitalRead(pb2);

if ((pbCode1 == HIGH) && (v1==0)) {
t = 0;
v1 = 1;
v2 = 0;
codeAct(1);
}

if ((pbCode2 == HIGH) && (v2==0)) {
t = 0;
v2 = 1;
v1 = 0;
codeAct(2);
}
}

void codeAct (int num)
{
switch (num)
{

case 1:

pbInc100= digitalRead(pb3);
pbInc10= digitalRead(pb4);
pbInc1= digitalRead(pb5);
pbStart= digitalRead(pb6);
pbReset= digitalRead(pb7);
encSwt= digitalRead(encswt);
if (t <= 0) {
t=0;
}
if (t = 3000) {
t=0;
}

if ((pbInc1 == HIGH)&&(v5==0)) {
v5=1;
t=t+1;

if ((t==10)||(t==20)||(t==30)||(t==40)||(t==50)||(t==60)||(t==70)||(t==80)||(t==90)||
(t==110)||(t==120)||(t==130)||(t==140)||(t==150)||(t==160)||(t==170)||(t==180)||(t==190)||
(t==210)||(t==220)||(t==230)||(t==240)||(t==250)||(t==260)||(t==270)||(t==280)||(t==290)||
(t==310)||(t==320)||(t==330)||(t==340)||(t==350)||(t==360)||(t==370)||(t==380)||(t==390)||
(t==410)||(t==420)||(t==430)||(t==440)||(t==450)||(t==460)||(t==470)||(t==480)||(t==490)||
(t==510)||(t==520)||(t==530)||(t==540)||(t==550)||(t==560)||(t==570)||(t==580)||(t==590)||
(t==610)||(t==620)||(t==630)||(t==640)||(t==650)||(t==660)||(t==670)||(t==680)||(t==690)||
(t==710)||(t==720)||(t==730)||(t==740)||(t==750)||(t==760)||(t==770)||(t==780)||(t==790)||
(t==810)||(t==820)||(t==830)||(t==840)||(t==850)||(t==860)||(t==870)||(t==880)||(t==890)||
(t==910)||(t==920)||(t==930)||(t==940)||(t==950)||(t==960)||(t==970)||(t==980)||(t==990)
||
(t==1110)||(t==1120)||(t==1130)||(t==1140)||(t==1150)||(t==1160)||(t==1170)||(t==1180)||(t==1190)||
(t==1210)||(t==1220)||(t==1230)||(t==1240)||(t==1250)||(t==1260)||(t==1270)||(t==1280)||(t==1290)||
(t==1310)||(t==1320)||(t==1330)||(t==1340)||(t==1350)||(t==1360)||(t==1370)||(t==1380)||(t==1390)||
(t==1410)||(t==1420)||(t==1430)||(t==1440)||(t==1450)||(t==1460)||(t==1470)||(t==1480)||(t==1490)||
(t==1510)||(t==1520)||(t==1530)||(t==1540)||(t==1550)||(t==1560)||(t==1570)||(t==1580)||(t==1590)||
(t==1610)||(t==1620)||(t==1630)||(t==1640)||(t==1650)||(t==1660)||(t==1670)||(t==1680)||(t==1690)||
(t==1710)||(t==1720)||(t==1730)||(t==1740)||(t==1750)||(t==1760)||(t==1770)||(t==1780)||(t==1790)||
(t==1810)||(t==1820)||(t==1830)||(t==1840)||(t==1850)||(t==1860)||(t==1870)||(t==1880)||(t==1890)||
(t==1910)||(t==1920)||(t==1930)||(t==1940)||(t==1950)||(t==1960)||(t==1970)||(t==1980)||(t==1990)
||
(t==2110)||(t==2120)||(t==2130)||(t==2140)||(t==2150)||(t==2160)||(t==2170)||(t==2180)||(t==2190)||
(t==2210)||(t==2220)||(t==2230)||(t==2240)||(t==2250)||(t==2260)||(t==2270)||(t==2280)||(t==2290)||
(t==2310)||(t==2320)||(t==2330)||(t==2340)||(t==2350)||(t==2360)||(t==2370)||(t==2380)||(t==2390)||
(t==2410)||(t==2420)||(t==2430)||(t==2440)||(t==2450)||(t==2460)||(t==2470)||(t==2480)||(t==2490)||
(t==2510)||(t==2520)||(t==2530)||(t==2540)||(t==2550)||(t==2560)||(t==2570)||(t==2580)||(t==2590)||
(t==2610)||(t==2620)||(t==2630)||(t==2640)||(t==2650)||(t==2660)||(t==2670)||(t==2680)||(t==2690)||
(t==2710)||(t==2720)||(t==2730)||(t==2740)||(t==2750)||(t==2760)||(t==2770)||(t==2780)||(t==2790)||
(t==2810)||(t==2820)||(t==2830)||(t==2840)||(t==2850)||(t==2860)||(t==2870)||(t==2880)||(t==2890)||
(t==2910)||(t==2920)||(t==2930)||(t==2940)||(t==2950)||(t==2960)||(t==2970)||(t==2980)||(t==2990)) {
t=t-10;
}
}

if ((pbInc1 == LOW)&&(v5=1)) {
v5=0;
t=t;
}

if ((pbInc10 == HIGH)&&(v4==0)) {
v4=1;
t=t+10;

if (
(t==100)||(t==200)||(t==300)||(t==400)||(t==500)||(t==600)||(t==700)||(t==800)||(t==900)||
(t==1100)||(t==1200)||(t==1300)||(t==1400)||(t==1500)||(t==1600)||(t==1700)||(t==1800)||(t==1900)||
(t==2100)||(t==2200)||(t==2300)||(t==2400)||(t==2500)||(t==2600)||(t==2700)||(t==2800)||(t==2900)||
(t==3100)||(t==3200)||(t==3300)||(t==3400)||(t==3500)||(t==3600)||(t==3700)||(t==3800)||(t==3900)||
(t==4100)||(t==4200)||(t==4300)||(t==4400)||(t==4500)||(t==4600)||(t==4700)||(t==4800)||(t==4900)||
(t==5100)||(t==5200)||(t==5300)||(t==5400)||(t==5500)||(t==5600)||(t==5700)||(t==5800)||(t==5900)||
(t==6100)||(t==6200)||(t==6300)||(t==6400)||(t==6500)||(t==6600)||(t==6700)||(t==6800)||(t==6900)||
(t==7100)||(t==7200)||(t==7300)||(t==7400)||(t==7500)||(t==7600)||(t==7700)||(t==7800)||(t==7900)||
(t==8100)||(t==8200)||(t==8300)||(t==8400)||(t==8500)||(t==8600)||(t==8700)||(t==8800)||(t==8900)||
(t==9100)||(t==9200)||(t==9300)||(t==9400)||(t==9500)||(t==9600)||(t==9700)||(t==9800)||(t==9900)) {
t=t-100;
}
}

if ((pbInc10 == LOW)&&(v4=1)) {
v4=0;
t=t;
}

if ((pbInc100 == HIGH)&&(v3==0)) {
v3=1;
t=t+100;

}
if ((pbInc100 == LOW)&&(v3=1)) {
v3=0;
t=t;
}

if ((pbReset == HIGH)&&(v7==0)) {
v7=1;
t=0;
}
if ((pbReset == LOW)&&(v7=1)) {
v7=0;
t=t;
}

if ((encSwt == HIGH)&&(enV==0)) {
enV=1;
encoder=encoder+1;
if(encoder==((100/24)*20)) {
t=t-1;
encoder=0;
}

}
if ((encSwt == LOW)&&(enV=1)) {
enV=0;
t=t;
}

i=t/1000;
j=(t-(i1000))/100;
k=(t-((i
1000)+(j100)))/10;
l=(t-((i
1000)+(j100)+(k10)));

{
turnOnSquare(1);
displayDigit(i);
delay(2);

turnOnSquare(2);
displayDigit(j);
delay(2);

turnOnSquare(3);
displayDigit(k);
delay(2);

turnOnSquare(4);
displayDigit(l);
delay(2);
}
if ((pbStart == HIGH) && (v6 == 0) && (t > 0)){
digitalWrite(relay, HIGH);

}

break;

case 2 :

if ((encSwt == HIGH)&&(enV==0)) {
enV=1;
encoder=encoder+1;
if(encoder==((100/24)*20)) {
t=t+1;
encoder=0;
}

i=t/1000;
j=(t-(i1000))/100;
k=(t-((i
1000)+(j100)))/10;
l=(t-((i
1000)+(j100)+(k10)));

{
turnOnSquare(1);
displayDigit(i);
delay(2);

turnOnSquare(2);
displayDigit(j);
delay(2);

turnOnSquare(3);
displayDigit(k);
delay(2);

turnOnSquare(4);
displayDigit(l);
delay(2);
}

if ((pbStart == HIGH) && (v6 == 0) && (t > 0)){
digitalWrite(relay, HIGH);

}

break;
}
}
}

void turnOnSquare (int num)
{
int d1=9, d2=10, d3=11, d4=12;
switch(num)
{
case 1:
digitalWrite(d1, LOW);
digitalWrite(d2, HIGH);
digitalWrite(d3, HIGH);
digitalWrite(d4, HIGH);
break;

case 2:
digitalWrite(d2, LOW);
digitalWrite(d1, HIGH);
digitalWrite(d3, HIGH);
digitalWrite(d4, HIGH);
break;

case 3:
digitalWrite(d3, LOW);
digitalWrite(d2, HIGH);
digitalWrite(d1, HIGH);
digitalWrite(d4, HIGH);
break;

case 4:
digitalWrite(d4, LOW);
digitalWrite(d2, HIGH);
digitalWrite(d3, HIGH);
digitalWrite(d1, HIGH);
break;

}
}

void displayDigit(int num)
{
switch (num)
{
case 0:
PORTD=B11111100;
digitalWrite(8, LOW);
break;

case 1:
PORTD=B00011000;
digitalWrite(8, LOW);
break;

case 2:
PORTD=B01101100;
digitalWrite(8, HIGH);
break;

case 3:
PORTD=B00111100;
digitalWrite(8, HIGH);
break;

case 4:
PORTD=B10011000;
digitalWrite(8, HIGH);
break;

case 5:
PORTD=B10110100;
digitalWrite(8, HIGH);
break;

case 6:
PORTD=B11110100;
digitalWrite(8, HIGH);
break;

case 7:
PORTD=B00011100;
digitalWrite(8, LOW);
break;

case 8:
PORTD=B11111100;
digitalWrite(8, HIGH);
break;

case 9:
PORTD=B10111100;
digitalWrite(8, HIGH);
break;
}
}

Can anyone help…

Rather than "two programs", think " two functions"

Please use code tags when posting code.

study the "modulo" operator.. Can simlify your code A LOT

 if ((t==10)||(t==20)||(t==30)||(t==40)||(t==50)||(t==60)||(t==70)||(t==80)||(t==90)||
          (t==110)||(t==120)||(t==130)||(t==140)||(t==150)||(t==160)||(t==170)||(t==180)||(t==190)||
          (t==210)||(t==220)||(t==230)||(t==240)||(t==250)||(t==260)||(t==270)||(t==280)||(t==290)||
          (t==310)||(t==320)||(t==330)||(t==340)||(t==350)||(t==360)||(t==370)||(t==380)||(t==390)||
          (t==410)||(t==420)||(t==430)||(t==440)||(t==450)||(t==460)||(t==470)||(t==480)||(t==490)||
          (t==510)||(t==520)||(t==530)||(t==540)||(t==550)||(t==560)||(t==570)||(t==580)||(t==590)||
          (t==610)||(t==620)||(t==630)||(t==640)||(t==650)||(t==660)||(t==670)||(t==680)||(t==690)||
          (t==710)||(t==720)||(t==730)||(t==740)||(t==750)||(t==760)||(t==770)||(t==780)||(t==790)||
          (t==810)||(t==820)||(t==830)||(t==840)||(t==850)||(t==860)||(t==870)||(t==880)||(t==890)||
          (t==910)||(t==920)||(t==930)||(t==940)||(t==950)||(t==960)||(t==970)||(t==980)||(t==990)
          ||
          (t==1110)||(t==1120)||(t==1130)||(t==1140)||(t==1150)||(t==1160)||(t==1170)||(t==1180)||(t==1190)||
          (t==1210)||(t==1220)||(t==1230)||(t==1240)||(t==1250)||(t==1260)||(t==1270)||(t==1280)||(t==1290)||
          (t==1310)||(t==1320)||(t==1330)||(t==1340)||(t==1350)||(t==1360)||(t==1370)||(t==1380)||(t==1390)||
          (t==1410)||(t==1420)||(t==1430)||(t==1440)||(t==1450)||(t==1460)||(t==1470)||(t==1480)||(t==1490)||
          (t==1510)||(t==1520)||(t==1530)||(t==1540)||(t==1550)||(t==1560)||(t==1570)||(t==1580)||(t==1590)||
          (t==1610)||(t==1620)||(t==1630)||(t==1640)||(t==1650)||(t==1660)||(t==1670)||(t==1680)||(t==1690)||
          (t==1710)||(t==1720)||(t==1730)||(t==1740)||(t==1750)||(t==1760)||(t==1770)||(t==1780)||(t==1790)||
          (t==1810)||(t==1820)||(t==1830)||(t==1840)||(t==1850)||(t==1860)||(t==1870)||(t==1880)||(t==1890)||
          (t==1910)||(t==1920)||(t==1930)||(t==1940)||(t==1950)||(t==1960)||(t==1970)||(t==1980)||(t==1990)
           ||
          (t==2110)||(t==2120)||(t==2130)||(t==2140)||(t==2150)||(t==2160)||(t==2170)||(t==2180)||(t==2190)||
          (t==2210)||(t==2220)||(t==2230)||(t==2240)||(t==2250)||(t==2260)||(t==2270)||(t==2280)||(t==2290)||
          (t==2310)||(t==2320)||(t==2330)||(t==2340)||(t==2350)||(t==2360)||(t==2370)||(t==2380)||(t==2390)||
          (t==2410)||(t==2420)||(t==2430)||(t==2440)||(t==2450)||(t==2460)||(t==2470)||(t==2480)||(t==2490)||
          (t==2510)||(t==2520)||(t==2530)||(t==2540)||(t==2550)||(t==2560)||(t==2570)||(t==2580)||(t==2590)||
          (t==2610)||(t==2620)||(t==2630)||(t==2640)||(t==2650)||(t==2660)||(t==2670)||(t==2680)||(t==2690)||
          (t==2710)||(t==2720)||(t==2730)||(t==2740)||(t==2750)||(t==2760)||(t==2770)||(t==2780)||(t==2790)||
          (t==2810)||(t==2820)||(t==2830)||(t==2840)||(t==2850)||(t==2860)||(t==2870)||(t==2880)||(t==2890)||
          (t==2910)||(t==2920)||(t==2930)||(t==2940)||(t==2950)||(t==2960)||(t==2970)||(t==2980)||(t==2990))

I think you mean "if t is between 10 and 2990 and divisible by 10" If so then investigate the modulo operator (%)

thanks for the answers, but my problem is not with the OR conditions. I want to shift from another 'function' to another using push buttons. Can i do it using 'if' ?

the encoder will act differently in the functions, one decrementing the count 't', the other incrementing the count

Ard19:
thanks for the answers, but my problem is not with the OR conditions. I want to shift from another ‘function’ to another using push buttons. Can i do it using ‘if’ ?

Something like this

set state = true
start of loop
  when the button is pressed set state to !state  //note WHEN not IF the button is pressed
  if state is true
    functionA()
  end of if
  else
    functionB()
  end of else
end of loop

If the functions are such that they don’t return to the calling program then you must read the button inside the functions and force a return when it is pressed.

im a bit confused about the function to used for 'when'. Can i get a small example?

Say 1 function to light LED 1 with push button 1 and LED 2 with push button 2, then use another push button to switch to another function where push button 1 is used to light up LED2 and push button 2 for LED 1.

Any help....

Ard19: thanks for the answers, but my problem is not with the OR conditions.

Yes it is, that piece of code shows that you have little idea as to what code is all about. That means you can not think correctly about addressing your problem.

Ard19: the encoder will act differently in the functions, one decrementing the count 't', the other incrementing the count

So you pass a value into your function which is either -1 or +1 and use that variable as an increment.

when the button is pressed set state to !state

if(digitalRead(buttonPin) == LOW) state = !state;

im a bit confused about the function to used for 'when'. Can i get a small example?

What I had in mind was that you probably want to know when the button becomes pressed, not if it is continuously pressed. If so, what you do is to to save the state of the button in a variable and compare it with the value the next time that you read the button.

If it was HIGH last time and is now LOW then you know that it has just been pressed (assuming a pull up resistor is used). If it was LOW last time and is still LOW then you know that it has remained pressed since the last check. In which case you may not want to run the function again, but could if you wanted to, of course.

thanks Mike. i know my code can be simplified but a beginner and i hve not read on all the functions yet. i tried to use the button state but it won't work. i will try to use the second pin on the encoder to increment the count..

What is this "button state" you have tried to use?

i tried to use the button state but it won't work

My blood pressure just shot up.

i've seen my mistakes.. instead of using two different functions i will be using a push button to light up an LED. If the LED is HIGH the count will increase, if LED is LOW the count will decrease.

Due to lack of number of pins on the UNO board im trying to use a shift register to be able to use less wires but again some difficulties. I tried to use part of a program which has been posted online for temperature display using a common anode 4 digit 7 segment display. For my project im using a common cathode one and the problem is that instead of having 1 digit being on at a time, im getting three on(which are supposed to be off)..

Any help... And thank you all for having answering my queries..

the code i’ve used is as follows:

const int digitPins[4] = {
4,5,6,7}; //4 common anode pins of the display
const int clockPin = 11; //74HC595 Pin 11
const int latchPin = 12; //74HC595 Pin 12
const int dataPin = 13; //74HC595 Pin 14

const byte digit[10] = //seven segment digits in bits
{
B00111111, //0
B00000110, //1
B01011011, //2
B01001111, //3
B01100110, //4
B01101101, //5
B01111101, //6
B00000111, //7
B01111111, //8
B01101111 //9
};
int digitBuffer[4] = {
0};
int digitScan = 0;

void setup(){
for(int i=0;i<4;i++)
{
pinMode(digitPins*,OUTPUT);*

  • }*

  • pinMode(latchPin, OUTPUT);*

  • pinMode(clockPin, OUTPUT);*

  • pinMode(dataPin, OUTPUT); *

}

//writes the temperature on display
void updateDisp(){

  • for(byte j=0; j<4; j++) *

  • digitalWrite(digitPins[j], LOW);*

  • digitalWrite(latchPin, LOW); *

  • shiftOut(dataPin, clockPin, MSBFIRST, B11111111);*

  • digitalWrite(latchPin, HIGH);*

  • delayMicroseconds(100);*

  • digitalWrite(digitPins[digitScan], HIGH);*

  • digitalWrite(latchPin, LOW); *

  • shiftOut(dataPin, clockPin, MSBFIRST, digit[digitBuffer[digitScan]]);*

  • digitalWrite(latchPin, HIGH);*

  • digitScan++;*

  • if(digitScan>3) digitScan=0;*
    }

void loop(){

  • digitBuffer[3] = 2;*
  • digitBuffer[2] = 6;*
  • digitBuffer[1] = 5;*
  • digitBuffer[0] = 4;*
  • updateDisp();*
  • delay(2000);*
    }[/quote]

In your Arduino IDE: Select Tools->Auto Format Do not proceed until Auto Format works without errors. Click in the editor window Press CTRL+A to select all text in the editor window Press CTRL+C to copy the text

In the forum Editor: Click on the # icon above the window Press CTRL-V to paste the text.

When you make changes to your code, post it again

When it doesn't work, tell us what it does that you didn't expect, or what it didn't do that you expected it to do.

The code i’ve posted is the one i’ve edited, i tried to display
number 4 on the 1st digit,
number 5 on the 2nd digit,
number 6 on 3rd digit and
number 2 on 4th digit.

The result is
number 4 on 2nd, 3rd and 4th digits,
number 5 on 1st, 3rd and 4th digits,
number 6 on 1st, 2nd and 4th digits,
number 2 on 1st, 2nd and 3rd digits.

I’ve increased the delay to see what was being displayed (from delay(2) to delay(2000) )

Thanks…

Ard19:
the code i’ve used is as follows:

const int digitPins[4] = {
4,5,6,7}; //4 common anode pins of the display
const int clockPin = 11; //74HC595 Pin 11
const int latchPin = 12; //74HC595 Pin 12
const int dataPin = 13; //74HC595 Pin 14



void loop(){

digitBuffer[3] = 2;
digitBuffer[2] = 6;
digitBuffer[1] = 5;
digitBuffer[0] = 4;
updateDisp();
delay(2000);
}

looks like you’re "running two different programs on one forum thread !!

use the CODE tag, NOT the QUOTE.

and THIS nonsense;

if ((t==10)||(t==20)||(t==30)||(t==40)||(t==50)||(t==60)||(t==70)||(t==80)||(t==90)||
          (t==110)||(t==120)||(t==130)||(t==140)||(t==150)||(t==160)||(t==170)||(t==180)||(t==190)||
          (t==210)||(t==220)||(t==230)||(t==240)||(t==250)||(t==260)||(t==270)||(t==280)||(t==290)||
          (t==310)||(t==320)||(t==330)||(t==340)||(t==350)||(t==360)||(t==370)||(t==380)||(t==390)||
          (t==410)||(t==420)||(t==430)||(t==440)||(t==450)||(t==460)||(t==470)||(t==480)||(t==490)||
          (t==510)||(t==520)||(t==530)||(t==540)||(t==550)||(t==560)||(t==570)||(t==580)||(t==590)||
          (t==610)||(t==620)||(t==630)||(t==640)||(t==650)||(t==660)||(t==670)||(t==680)||(t==690)||
          (t==710)||(t==720)||(t==730)||(t==740)||(t==750)||(t==760)||(t==770)||(t==780)||(t==790)||
          (t==810)||(t==820)||(t==830)||(t==840)||(t==850)||(t==860)||(t==870)||(t==880)||(t==890)||
          (t==910)||(t==920)||(t==930)||(t==940)||(t==950)||(t==960)||(t==970)||(t==980)||(t==990)
          ||
          (t==1110)||(t==1120)||(t==1130)||(t==1140)||(t==1150)||(t==1160)||(t==1170)||(t==1180)||(t==1190)||
          (t==1210)||(t==1220)||(t==1230)||(t==1240)||(t==1250)||(t==1260)||(t==1270)||(t==1280)||(t==1290)||
          (t==1310)||(t==1320)||(t==1330)||(t==1340)||(t==1350)||(t==1360)||(t==1370)||(t==1380)||(t==1390)||
          (t==1410)||(t==1420)||(t==1430)||(t==1440)||(t==1450)||(t==1460)||(t==1470)||(t==1480)||(t==1490)||
          (t==1510)||(t==1520)||(t==1530)||(t==1540)||(t==1550)||(t==1560)||(t==1570)||(t==1580)||(t==1590)||
          (t==1610)||(t==1620)||(t==1630)||(t==1640)||(t==1650)||(t==1660)||(t==1670)||(t==1680)||(t==1690)||
          (t==1710)||(t==1720)||(t==1730)||(t==1740)||(t==1750)||(t==1760)||(t==1770)||(t==1780)||(t==1790)||
          (t==1810)||(t==1820)||(t==1830)||(t==1840)||(t==1850)||(t==1860)||(t==1870)||(t==1880)||(t==1890)||
          (t==1910)||(t==1920)||(t==1930)||(t==1940)||(t==1950)||(t==1960)||(t==1970)||(t==1980)||(t==1990)
           ||
          (t==2110)||(t==2120)||(t==2130)||(t==2140)||(t==2150)||(t==2160)||(t==2170)||(t==2180)||(t==2190)||
          (t==2210)||(t==2220)||(t==2230)||(t==2240)||(t==2250)||(t==2260)||(t==2270)||(t==2280)||(t==2290)||
          (t==2310)||(t==2320)||(t==2330)||(t==2340)||(t==2350)||(t==2360)||(t==2370)||(t==2380)||(t==2390)||
          (t==2410)||(t==2420)||(t==2430)||(t==2440)||(t==2450)||(t==2460)||(t==2470)||(t==2480)||(t==2490)||
          (t==2510)||(t==2520)||(t==2530)||(t==2540)||(t==2550)||(t==2560)||(t==2570)||(t==2580)||(t==2590)||
          (t==2610)||(t==2620)||(t==2630)||(t==2640)||(t==2650)||(t==2660)||(t==2670)||(t==2680)||(t==2690)||
          (t==2710)||(t==2720)||(t==2730)||(t==2740)||(t==2750)||(t==2760)||(t==2770)||(t==2780)||(t==2790)||
          (t==2810)||(t==2820)||(t==2830)||(t==2840)||(t==2850)||(t==2860)||(t==2870)||(t==2880)||(t==2890)||
          (t==2910)||(t==2920)||(t==2930)||(t==2940)||(t==2950)||(t==2960)||(t==2970)||(t==2980)||(t==2990)) {
      t=t-10;
    }

means you are long overdue to learn about using the modulo function.

change “int digitBuffer[4]” to byte digitBuffer[4]
…looks like you put out highbyte of an 16 bit value containg numbers<256 (always 0)

Ard19:
the code i’ve used is as follows:

const int digitPins[4] = {
4,5,6,7}; //4 common anode pins of the display
const int clockPin = 11; //74HC595 Pin 11
const int latchPin = 12; //74HC595 Pin 12
const int dataPin = 13; //74HC595 Pin 14

const byte digit[10] = //seven segment digits in bits
{
B00111111, //0
B00000110, //1
B01011011, //2
B01001111, //3
B01100110, //4
B01101101, //5
B01111101, //6
B00000111, //7
B01111111, //8
B01101111 //9
};
int digitBuffer[4] = {
0};
int digitScan = 0;

void setup(){
for(int i=0;i<4;i++)
{
pinMode(digitPins*,OUTPUT);*

  • }*

  • pinMode(latchPin, OUTPUT);*

  • pinMode(clockPin, OUTPUT);*

  • pinMode(dataPin, OUTPUT); *

}

//writes the temperature on display
void updateDisp(){

  • for(byte j=0; j<4; j++) *

  • digitalWrite(digitPins[j], LOW);*

  • digitalWrite(latchPin, LOW); *

  • shiftOut(dataPin, clockPin, MSBFIRST, B11111111);*

  • digitalWrite(latchPin, HIGH);*

  • delayMicroseconds(100);*

  • digitalWrite(digitPins[digitScan], HIGH);*

  • digitalWrite(latchPin, LOW); *

  • shiftOut(dataPin, clockPin, MSBFIRST, digit[digitBuffer[digitScan]]);*

  • digitalWrite(latchPin, HIGH);*

  • digitScan++;*

  • if(digitScan>3) digitScan=0;*
    }

void loop(){

  • digitBuffer[3] = 2;*
  • digitBuffer[2] = 6;*
  • digitBuffer[1] = 5;*
  • digitBuffer[0] = 4;*
  • updateDisp();*
  • delay(2000);*
    }[/quote]
    [/quote]