Help with coding...

Hi everyone I'm stuck on keypad, because I want 3 products like 111 beats per minute. So if I press 1 once then it saves it as a variable of 1, if i press it again it saves it in a another variable as 1, etc... Then calculates. The code supplied is what I have so far and kind of explains what is happening, thanks for the help to those who have contributed.

[u]Code V0.0:[/u]

"

#include "Arduino.h"
#include "Keypad.h"

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
              {'1','2','3'},
              {'4','5','6'},
              {'7','8','9'},
              {'*','0','#'}
            };
byte rowPins[ROWS] = {12, 11, 10, 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int VARone = 0;
int VARtwo = 0 ;
int VARthree = 0;
int One1 = 0;
int Two2 = 0;
int Three3 = 0;
int convert = 0;
int total = 0;
int RUN = 0;
int x = 0; 
int input = 0;
int varin = 0;
int count = 0;
int vardp = 0;
int varcalc = 1;

void setup() 
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(2,INPUT);
  pinMode(5,OUTPUT);
  pinMode(4,OUTPUT);
}

void loop() 
{
  // put your main code here, to run repeatedly:
  char key = keypad.getKey();
  
  if (digitalRead(2))
    {
    if( ( RUN ) == ( 0 ) )
    {
      varcalc = 0;
      VARone = 0;
      VARtwo = 0;
      VARthree = 0;
      One1 = 0;
      Two2 = 0;
      Three3 = 0;
      convert = 0;
      total = 0;
      RUN = 1;
    } 
    else
    {
      if( ((VARone) == (0)) && ((VARtwo)==(0)) && ((VARthree)==(0)) )
      {
        if(key)
        {
          switch (key)
          {
            case '0':
            One1 = 0;
            varcalc = 0;
            VARone = 1;
            break;
            case '1':
            One1 = 1;
            varcalc = 0;
            VARone = 1;
            break;
            case '2':
            One1 = 2;
            varcalc = 0;
            VARone = 1;
            break;
            case '3':
            One1 = 3;
            varcalc = 0;
            VARone = 1;
            break;
            case '4':
            One1 = 4;
            varcalc = 0;
            VARone = 1;
            break;
            case '5':
            One1 = 5;
            varcalc = 0;
            VARone = 1;
            break;
            case '6':
            One1 = 6;
            varcalc = 0;
            VARone = 1;
            break;
            case '7':
            One1 = 7;
            varcalc = 0;
            VARone = 1;
            break;
            case '8':
            One1 = 8;
            varcalc = 0;
            VARone = 1;
            break;
            case '9':
            One1 = 9;
            varcalc = 0;
            VARone = 1;
            break;
          }
        }
      }
        else
        {
          if( ((VARone) == (1)) && ((VARtwo)==(0)) && ((VARthree)==(0)) )
          {
            if(key)
            {
            switch (key)
            {
              case '0':
              Two2 = 0;
              varcalc = 0;
              VARtwo = 1;
              break;
              case '1':
              Two2 = 1;
              varcalc = 0;
              VARtwo = 1;
              break;
              case '2':
              Two2 = 2;
              varcalc = 0;
              VARtwo = 1;
              break;
              case '3':
              Two2 = 3;
              varcalc = 0;
              VARtwo = 1;
              break;
              case '4':
              Two2 = 4;
              varcalc = 0;
              VARtwo = 1;
              break;
              case '5':
              Two2 = 5;
              varcalc = 0;
              VARtwo = 1;
              break;
              case '6':
              Two2 = 6;
              varcalc = 0;
              VARtwo = 1;
              break;
              case '7':
              Two2 = 7;
              varcalc = 0;
              VARtwo = 1;
              break;
              delay(11);
              case '8':
              Two2 = 8;
              varcalc = 0;
              VARtwo = 1;
              break;
              case '9':
              Two2 = 9;
              varcalc = 0;
              VARtwo = 1;
              break;
            }
          }
        }
        else
        {
          if( ((VARone) == (1)) && ((VARtwo)==(1)) && ((VARthree)==(0)) )
          {
            if(key)
            {
              switch (key)
              {
                case '0':
                Three3 = 0;
                varcalc = 0;
                VARthree = 1;
                break;
                case '1':
                Three3 = 1;
                varcalc = 0;
                VARthree = 1;
                break;
                case '2':
                Three3 = 2;
                varcalc = 0;
                VARthree = 1;
                break;
                case '3':
                Three3 = 3;
                varcalc = 0;
                VARthree = 1;
                break;
                delay(11);
                case '4':
                Three3 = 4;
                varcalc = 0;
                VARthree = 1;
                break;
                case '5':
                Three3 = 5;
                varcalc = 0;
                VARthree = 1;
                break;
                case '6':
                Three3 = 6;
                varcalc = 0;
                VARthree = 1;
                break;
                delay(11);
                case '7':
                Three3 = 7;
                varcalc = 0;
                VARthree = 1;
                break;
                case '8':
                Three3 = 8;
                varcalc = 0;
                VARthree = 1;
                break;
                case '9':
                Three3 = 9;
                varcalc = 0;
                VARthree = 1;
                break;
                delay(11);
              }
            }
          }
        }
      }
    }
  }
    else
    {
    if( ( varcalc ) == ( 0 ) )
    {
      if( ((VARone) == (1)) && ((VARtwo)==(0)) && ((VARthree)==(0)) )
      {
            convert = ((60000)/(One1));
            varcalc = 1;
      }
      else
      {
        if( ((VARone) == (1)) && ((VARtwo)==(1)) && ((VARthree)==(0)) )
        {
          total =  ( ( (One1) * (10) ) + ( (Two2)  ) ) ;
          convert = ( ( 60000 )/ ( total ) );
          varcalc = 1;
        }
        else
        {
          if( ((VARone) == (1)) && ((VARtwo)==(1)) && ((VARthree)==(1)) )
          {
            total = ( ( ( (One1) * (1000) ) + ( (Two2) * (100) ) ) +  ( Three3 ) );
            convert = ( ( 60000 )/ ( total ) );
            varcalc = 1;
          }
          else
          {
            varcalc = 1;
          }
        }
      }
        }
    else
        {
      RUN = 0 ;
      digitalWrite(4,HIGH);
      analogWrite(5,255);
      delay( 11 );
      analogWrite(5,0);
      digitalWrite(4,LOW);
      delay( convert );
        } 
    }
}

"

It's hard to tell what's going on and what's supposed to happen, but I can tell you that all the delays between a "break" and the next "case" will never get executed, so they may as well not be there. Something that isn't there but should be, is a pair of code tags.

if( ((VARone) == (0)) && ((VARtwo)==(0)) && ((VARthree)==(0)) )

(Why) do (you) have (so) many (unnecessary) parentheses?

Hi everyone I updated the post to an extent that if you choose a number i.e. 111 and follow the code it would make sense and special thanks to AWOL for the help and look forward this project working.

…and now you’ve edited the original post, so my earlier comments don’t make any sense, and you’ve still not got any code tags.

Good luck.

Code-shortening hint

if(key >= '0' && key <= '9')
{
  One1 = key - '0';
  varcalc = 0;
  VARone = 1;
}

etc.

New Update evryone

R10_JR: New Update evryone

That's the second time you've posted that, but I see no update.

Edit: {light dawns} You've edited the original post (still no code tags), so nothing makes sense.

Do you want a forum timeout?

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.

Thanks.. Tom... :)

Update: Form and Code. 06/08/2016

Hi, PLEASE DO NOT KEEP GOING BACK AND UPDATING/EDITING YOUR FIRST POST. You are not helping others to help you by changing the initial code you had problems with.

Each time you update YOUR CODE please post a NEW message with your updated code, NOT a message that says

New Update evryone

This forum is to help all users, so anyone who had a similar problem to you, SHOULD be able to follow how you solved your problem, by changing the initial post you are removing any hope of this thread being used to help other users.

SO PLEASE NEW MESSAGES EACH TIME, INCLUDING CODE UPDATES.

Thanks.. Tom... :)

Hi, How does the code know if you are putting in a 1 or 2 or 3 digit number? Would it be better to store each key press and look for a # press to be the equivalent of ENTER/CALCULATE?

You wouldn't need all these IF statements to check for number of digits and do the calculation? And you would be able to input any number of digits.

Tom... :)

Hi it saves like this for all three variables;

One1 = key - '0';//First variable

Two2 = key - '0';//Second variable

Three3 = key - '0';//Third variable

This is a new code version of V0.0 [u]Code V0.1:[/u]

#include "Keypad.h"

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
              {'1','2','3'},
              {'4','5','6'},
              {'7','8','9'},
              {'*','0','#'}
            };
byte rowPins[ROWS] = {12, 11, 10, 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int VARone = 0;
int VARtwo = 0 ;
int VARthree = 0;
int One1 = 0;
int Two2 = 0;
int Three3 = 0;
int total = 0;
int RUN = 0;
int varcalc = 1;

void setup() 
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(2,INPUT);
  pinMode(5,OUTPUT);
  pinMode(4,OUTPUT);
}

void loop() 
  {
    // put your main code here, to run repeatedly:
    char key = keypad.getKey();
    Serial.print(total);
    if (digitalRead(2))//Mode Loop
    {
        varcalc = 0;
        VARone = 0;
        VARtwo = 0;
        VARthree = 0;
        One1 = 0;
        Two2 = 0;
        Three3 = 0;
        total = 0;
    }
    else
    {
        //Keypad closed loop
        Serial.print(key);
        if((VARone)==(0))//Test if variable one is equal to 0
        {
          //Get key from 0 - 9 and set it to variable one
          delay(11);
          char key = keypad.getKey();
          if(key != NO_KEY)
          {
            One1 = (key);
            varcalc = 0;
            VARone = 1;
          }
        }
        else
        {
          if(((VARone)==(1))&&((VARtwo)==(0)))//Test variable one is equal to 1, whilst variable two is equal to 0
          {
            //Get key from 0 - 9 and set it to variable two
            delay(11);
            char key = keypad.getKey();
            if(key != NO_KEY)
            {
                Two2 = (key);
                varcalc = 0;
                VARtwo = 1;
            }
        }
        else
        {
            if(((VARone)==(1))&&((VARtwo)==(1))&&((VARthree)==(0)))//Test variable one and variable two is equal to 1, whilst variable three is equal to 0
            {
                //Get key from 0 - 9 and set it to variable three
                delay(11);
                char key = keypad.getKey();
                if(key != NO_KEY)
                {
                    Three3 = (key);
                    varcalc = 0;
                    VARthree = 1;
                }
            }
        }
        if((varcalc)==(0))//Calculation Loop
        {
            if((VARone)==(1))//Runs calculation when there is only one variable
            {
                total = (One1);//Takes one inputted number like; '5'
                varcalc = 1;
            }
            else
            {
                if(((VARone) == (1)) && ((VARtwo)==(1)))//Runs calculation when there is only two variables
                {
                    total =  (((One1)*(10))+((Two2)));//Takes two inputted numbers and calculates like; '60'
                    varcalc = 1;
                }
                else
                {
                    if(((VARone)==(1))&&((VARtwo)==(1))&&((VARthree)==(1)))//Runs calculation when there is only three variables
                    {
                      total = ((((One1)*(100) )+((Two2)*(10)))+(Three3));//Takes three inputted numbers and calculates like; '111'
                      varcalc = 1;
                    }
                    else
                    {
                      varcalc = 1;
                    }
                  }
                }
              }
              else//loop
              {
                  digitalWrite(4,HIGH);
                  analogWrite(5,255);
                  delay(11);
                  analogWrite(5,0);
                  digitalWrite(4,LOW);
                  delay((60000)/(total));//makes a delay, e.g. 60000/111 = 540.540540541ms
              }
         }
    }
}

((Why) (have you) (got so (many)) ((unnecessary)parentheses))?

This is a new code version of V0.1
Code V0.2:

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};
byte rowPins[ROWS] = {12, 11, 10, 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int VARone = 0;
int VARtwo = 0 ;
int VARthree = 0;
int One1 = 0;
int Two2 = 0;
int Three3 = 0;
int total = 0;
int RUN = 0;
int varcalc = 1;

void setup() 
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(2,INPUT);
  pinMode(5,OUTPUT);
  pinMode(4,OUTPUT);
}

void loop() 
	{
		// put your main code here, to run repeatedly:
		char key = keypad.getKey();
		Serial.println(total);
		if (digitalRead(2))//Reset Loop
		{
			varcalc = 1;
			VARone = 0;
			VARtwo = 0;
			VARthree = 0;
			One1 = 0;
			Two2 = 0;
			Three3 = 0;
			total = 0;
		}
		else
		{
			if((varcalc)==(1))//Keypad Loop
			{
				if((VARone)==(0))//Test if variable one is equal to 0
				{
					//Get key from 0 - 9 and set it to variable one
					char key = keypad.getKey();
					if(key != NO_KEY)
					{
						One1 = key;
						varcalc = 0;
						VARone = 1;
					}
				}
				else
				{
					if(((VARone)==(1))&&((VARtwo)==(0)))//Test variable one is equal to 1, whilst variable two is equal to 0
					{
						//Get key from 0 - 9 and set it to variable two
						char key = keypad.getKey();
						if(key != NO_KEY)
						{
							Two2 = key;
							varcalc = 0;
							VARtwo = 1;
						}
					}
					else
					{
						if(((VARone)==(1))&&((VARtwo)==(1))&&((VARthree)==(0)))//Test variable one and variable two is equal to 1, whilst variable three is equal to 0
						{
							//Get key from 0 - 9 and set it to variable three
							char key = keypad.getKey();
							if(key != NO_KEY)
							{
								Three3 = key;
								varcalc = 0;
								VARthree = 1;
							}
						}
					}
				}
			}
            else
			{
				if((varcalc)==(0))//Calculation Loop
				{
					if((VARone)==(1))//Runs calculation when there is only one variable
					{
						total = (One1);//Takes one inputted number like; '5'
						varcalc = 1;
					}
					else
					{
						if(((VARone) == (1)) && ((VARtwo)==(1)))//Runs calculation when there is only two variables
						{
							total =  (((One1)*(10))+((Two2)));//Takes two inputted numbers and calculates like; '60'
							varcalc = 1;
						}
						else
						{
							if(((VARone)==(1))&&((VARtwo)==(1))&&((VARthree)==(1)))//Runs calculation when there is only three variables
							{
								total = ((((One1)*(100) )+((Two2)*(10)))+(Three3));//Takes three inputted numbers and calculates like; '111'
								varcalc = 1;
							}
							else
							{
								varcalc = 1;
							}
						}
					}
				}
				else//loop
				{
					digitalWrite(4,HIGH);
					analogWrite(5,255);
					delay(11);
					analogWrite(5,0);
					digitalWrite(4,LOW);
					delay((60000)/(total));//makes a delay, e.g. 60000/111 = 540.540540541ms
				}
			}
        }
	}

Hi,

if((varcalc)==(1))//Keypad Loop

can be

if(varcalc==1)//Keypad Loop
if(((VARone)==(1))&&((VARtwo)==(1))&&((VARthree)==(1)))

can be

if((VARone==1)&&(VARtwo==1)&&(VARthree==1))

Tom..... :)

This is a new code version of V0.1

Code V0.2:

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};
byte rowPins[ROWS] = {12, 11, 10, 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int VARone = 0;
int VARtwo = 0 ;
int VARthree = 0;
int One1 = 0;
int Two2 = 0;
int Three3 = 0;
int total = 0;

void setup() 
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(2,INPUT);
  pinMode(5,OUTPUT);
  pinMode(4,OUTPUT);
}

void loop() 
  {
    // put your main code here, to run repeatedly:
    if (digitalRead(2))//Reset Loop
    {
      VARone = (0);
      VARtwo = (0);
      VARthree = (0);
      One1 = (0);
      Two2 = (0);
      Three3 = (0);
      total = (0);
    }
    else
    {
		if(digitalRead(3))//Calculation loop
		{
			
			if(VARone == 1)//Runs calculation when there is only one variable
			{
				total = (One1);//Takes one inputted number like; '5'
			}
			else
			{
				if((VARone == 1)&&(VARtwo == 1))//Runs calculation when there is only two variables
				{
					total =  (((One1)*(10))+((Two2)));//Takes two inputted numbers and calculates like; '60'
				}
				else
				{
					if((VARone == 1)&&(VARtwo == 1)&&(VARthree== 1))//Runs calculation when there is only three variables
					{
						total = ((((One1)*(100))+((Two2)*(10)))+(Three3));//Takes three inputted numbers and calculates like; '111'
					}
				}
			}
        }
		else//keypad loop
        {
			char key = keypad.getKey();
			Serial.println(One1);
			delay(11);
			if((VARone)==(0))//Test if variable one is equal to 0
			{
				//Get key from 0 - 9 and set it to variable one
				char key = keypad.getKey();
				if(key != NO_KEY)
				{
					One1==(key);
					VARone==1;
				}
			}
			else
			{
				delay(11);
				if(((VARone)==(1))&&((VARtwo)==(0)))//Test variable one is equal to 1, whilst variable two is equal to 0
				{
					//Get key from 0 - 9 and set it to variable two
					char key = keypad.getKey();
					if(key != NO_KEY)
					{
						Two2==(key);
						VARtwo==1;
					}
				}
				else
				{
					delay(11);
					if(((VARone)==(1))&&((VARtwo)==(1))&&((VARthree)==(0)))//Test variable one and variable two is equal to 1, whilst variable three is equal to 0
					{
						//Get key from 0 - 9 and set it to variable three
						char key = keypad.getKey();
						if(key != NO_KEY)
						{
							Three3==(key);
							VARthree==1;
						}
					}
					else//loop
					{
						digitalWrite(4,HIGH);
						analogWrite(5,255);
						delay(11);
						analogWrite(5,0);
						digitalWrite(4,LOW);
						delay((60000)/(total));//makes a delay, e.g. 60000/111 = 540.540540541ms
					}
				}
			}	
		}
        
    }
}

Hello Everyone I am very grateful for the help and I have the full working code for you guys for this is a silent metronome which vibrates to a BPM and will help other people will find this useful. Thanks for this everyone… :slight_smile:

CODE PT.1? V.F

#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {12, 11, 10, 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int VARdelay = 0;
int VARone = 0;
int VARtwo = 0;
int VARthree = 0;
int One1 = 0;
int Two2 = 0;
int VARtotal = 0;
void setup() 
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(2,INPUT);
  pinMode(5,OUTPUT);
  pinMode(4,OUTPUT);
}
void loop() 
 {
 // put your main code here, to run repeatedly:
 if((VARone)==(0))//Variable One: Calcuation and keypad setting from 0-9
 {
 delay(11);
 char key = keypad.getKey();
 Serial.println(VARdelay);
 if (key)
 {
 switch(key)
 {
 case '#':
 VARone = 1;
 VARtwo = 1;
 VARthree =1;
 break;
 case '0'://set variable one to this number
 One1 = 0;
 VARdelay = 60000;//set delay
 VARone = 1;
 break;
 case '1'://set variable one to this number
 One1 = 1;
 VARdelay = ((60000)/(1));//set delay
 VARone = 1;
 break;
 case '2'://set variable one to this number
 One1 = 2;
 VARdelay = ((60000)/(2));//set delay
 VARone = 1;
 break;
 case '3'://set variable one to this number
 One1 = 3;
 VARdelay = ((60000)/(3));//set delay
 VARone = 1;
 break;
 case '4'://set variable one to this number
 One1 = 4;
 VARdelay = ((60000)/(4));//set delay
 VARone = 1;
 break;
 case '5'://set variable one to this number
 One1 = 5;
 VARdelay = ((60000)/(5));//set delay
 VARone = 1;
 break;
 case '6'://set variable one to this number
 One1 = 6;
 VARdelay = ((60000)/(6));//set delay
 VARone = 1;
 break;
 case '7'://set variable one to this number
 One1 = 7;
 VARdelay = ((60000)/(7));//set delay
 VARone = 1;
 break;
 case '8'://set variable one to this number
 One1 = 8;
 VARdelay = ((60000)/(8));//set delay
 VARone = 1;
 break;
 case '9'://set variable one to this number
 One1 = 9;
 VARdelay = ((60000)/(9));//set delay
 VARone = 1;
 break;
 }
 }
 }
 else
 {
 if(((VARone)==(1))&&((VARtwo)==(0)))//Variable Two: Calculation and keypad setting from 0-9
 {
 delay(11);
 char key = keypad.getKey();
 Serial.println(VARdelay);
 if (key)
 {
 switch (key)
 {
 case '#':
 VARtwo = 1;
 VARthree =1;
 break;
 case '0'://set variable one to this number
 Two2 = 0;
 VARtotal = (((One1)*(10))+(0));//Caculation. If there is a previous calculation overwrite it
 VARdelay = ((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARtwo = 1;
 break;
 case '1'://set variable one to this number
 Two2 = 1;
 VARtotal = (((One1)*(10))+(1));//Caculation. If there is a previous calculation overwrite it
 VARdelay = ((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARtwo = 1;
 break;
 case '2'://set variable one to this number
 Two2 = 2;
 VARtotal = (((One1)*(10))+(2));//Caculation. If there is a previous calculation overwrite it
 VARdelay = ((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARtwo = 1;
 break;
 case '3'://set variable one to this number
 Two2 = 3;
 VARtotal = (((One1)*(10))+(3));//Caculation. If there is a previous calculation overwrite it
 VARdelay = ((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARtwo = 1;
 break;
 case '4'://set variable one to this number
 Two2 = 4;
 VARtotal = (((One1)*(10))+(4));//Caculation. If there is a previous calculation overwrite it
 VARdelay = ((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARtwo = 1;
 break;
 case '5'://set variable one to this number
 Two2 = 5;
 VARtotal = (((One1)*(10))+(5));//Caculation. If there is a previous calculation overwrite it
 VARdelay = ((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARtwo = 1;
 break;
 case '6'://set variable one to this number
 Two2 = 6;
 VARtotal = (((One1)*(10))+(6));//Caculation. If there is a previous calculation overwrite it
 VARdelay = ((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARtwo = 1;
 break;
 case '7'://set variable one to this number
 Two2 = 7;
 VARtotal = (((One1)*(10))+(7));//Caculation. If there is a previous calculation overwrite it
 VARdelay = ((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARtwo = 1;
 break;
 case '8'://set variable one to this number
 Two2 = 8;
 VARtotal = (((One1)*(10))+(8));//Caculation. If there is a previous calculation overwrite it
 VARdelay = ((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARtwo = 1;
 break;
 case '9'://set variable one to this number
 Two2 = 9;
 VARtotal = (((One1)*(10))+(9));//Caculation. If there is a previous calculation overwrite it
 VARdelay = ((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARtwo = 1;
 break; 
 }
 }
 }
 else
 {
 if(((VARone)==(1))&&((VARtwo)==(1))&&((VARthree)==(0)))//Variable Three: Calculation and keypad setting from 0-9
 {
 delay(11);
 char key = keypad.getKey();
 Serial.println(VARdelay);
 if (key)
 {
 switch (key)
 {
 case '#':
 VARthree = 1;
 break;
 case '0'://set variable one to this number
 VARtotal = (((One1)*(100))+((Two2)*(10))+(0));//Caculation. If there is a previous calculation overwrite it
 VARdelay =((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARthree = 1;
 break;
 case '1'://set variable one to this number
 VARtotal = (((One1)*(100))+((Two2)*(10))+(1));//Caculation. If there is a previous calculation overwrite it
 VARdelay =((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARthree = 1;
 break;
 case '2'://set variable one to this number
 VARtotal = (((One1)*(100))+((Two2)*(10))+(2));//Caculation. If there is a previous calculation overwrite it
 VARdelay =((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARthree = 1;
 break;
 case '3'://set variable one to this number
 VARtotal = (((One1)*(100))+((Two2)*(10))+(3));//Caculation. If there is a previous calculation overwrite it
 VARdelay =((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARthree = 1;
 break;
 case '4'://set variable one to this number
 VARtotal = (((One1)*(100))+((Two2)*(10))+(4));//Caculation. If there is a previous calculation overwrite it
 VARdelay =((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARthree = 1;
 break;
 case '5'://set variable one to this number
 VARtotal = (((One1)*(100))+((Two2)*(10))+(5));//Caculation. If there is a previous calculation overwrite it
 VARdelay =((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARthree = 1;
 break;
 case '6'://set variable one to this number
 VARtotal = (((One1)*(100))+((Two2)*(10))+(6));//Caculation. If there is a previous calculation overwrite it
 VARdelay =((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARthree = 1;
 break;
 case '7'://set variable one to this number
 VARtotal = (((One1)*(100))+((Two2)*(10))+(7));//Caculation. If there is a previous calculation overwrite it
 VARdelay =((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARthree = 1;
 break;
 case '8'://set variable one to this number
 VARtotal = (((One1)*(100))+((Two2)*(10))+(8));//Caculation. If there is a previous calculation overwrite it
 VARdelay =((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARthree = 1;
 break;
 case '9'://set variable one to this number
 VARtotal = (((One1)*(100))+((Two2)*(10))+(9));//Caculation. If there is a previous calculation overwrite it
 VARdelay =((60000)/(VARtotal));//Set delay. If there is a previous delay overwrite it
 VARthree = 1;
 break;
 }
 }
 }
 else
 {
 if(digitalRead(2))//Reset all int
 {
 VARone = 0;
 VARtwo = 0;
 VARthree = 0;
 One1 = 0;
 Two2 = 0;
 VARtotal = 0;
 VARdelay = 0;
 }
 else
 {
 Serial.println(1337);//LEET
 Serial.println(VARdelay);
 digitalWrite(5,HIGH);
 digitalWrite(4,255);
 delay(36);
 digitalWrite(4,0);
 digitalWrite(5,LOW);
 delay(VARdelay);
 Serial.println(1337);//LEET
 }
 }
 }
 }
 }

See reply #3.