user60439: ok so I dont actually know anything about coding or electronics outside of being an electrician. This is something i've been working on for about a month.
I may be asking something dumb but here it is.
also i dont know where to put my code so ill put it in the comments (sorry).
so basically I want a visual metronome. I want to plug a control box into the wall, plug a lamp into the control box to blink at a set interval. the box will have a rotary encoder and lcd display to control the beats per minute. to achieve this im gonna use a SSR and some transformers to achieve a variety of voltages for different led lights. but I want to affect a 120v cct to do it all. but I just want to get the code down before I build it so im trying to blink the onboard led on my arduino uno for now.
I have the code, which is 3 different sketches, frankensteined together. probably poorly. 
I added an arithmetic equation to facilitate the metronome timing but I cant transfer that value to the "interval" for the blinking light. 
In my serial viewer, the equation works and it gives me the values I desire. I just cant get that into the interval.
the math equation is simple
(60/bpm)1000 = intended interval
example: (60/120)1000 = 500 as the milli interval for the blinking light. 2 blinks per second.
enter code here





// rotary encoder -----------------

int val;
int encoder0PinA = 6;
int encoder0PinB = 7;
int encoder0Pos = 59;
int encoder0PinALast = LOW;
int n = LOW;

// lcd screen ---------------------

     // include the library code:
#include <LiquidCrystal.h>

     // initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


// led blink ----------------------

     // the number of the LED pin
const int ledPin =  LED_BUILTIN;

     // ledState used to set the LED
int ledState = LOW;             

     // will store last time LED was updated
unsigned long previousMillis = 0;      

     // interval at which to blink (milliseconds) --    long interval = ;


// mathssss -----------------------

float a = (60 / encoder0Pos) * 1000;



// on to setup -------------------------------------------------------



void setup() {
      // put your setup code here, to run once:




// rotary encoder ---------------
 pinMode (encoder0PinA, INPUT);
  pinMode (encoder0PinB, INPUT);
  Serial.begin (9600);



  Serial.println ("hi");

// lcd screen -------------------
      // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
      // Print a message to the LCD.
  lcd.print("BeatsPerMinute");

// led blink -------------------
pinMode(ledPin, OUTPUT);

}


// on to loop --------------------------------------------------------
void loop() {
      // put your main code here, to run repeatedly:
      long interval = (60.00 / encoder0Pos) * 1000;

// rotary encoder --------------
  n = digitalRead(encoder0PinA);
  if ((encoder0PinALast == LOW) && (n == HIGH)) {
    if (digitalRead(encoder0PinB) == LOW) {
      encoder0Pos--;
    } else {
      encoder0Pos++;
    }

     // serial ----------------------------------------------------------------------
  Serial.println ("BPM");
  Serial.println (encoder0Pos);
  Serial.println ("interval");
  Serial.println (interval);
  Serial.println ("intended interval");
  Serial.println (60.00 / encoder0Pos * 1000, 8);
  Serial.println ("----------------");
     // serial done -----------------------------------------------------------------
  }
  encoder0PinALast = n;

  // lcd screen ----------------

       // set the cursor to column 0, line 1
       // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
       // print the number of seconds since reset:
  lcd.print(encoder0Pos);

  // led blink -----------------

    unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
      previousMillis = currentMillis;    
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }


    digitalWrite(ledPin, ledState);

 // serial --------------------


 // done


  }

}


user42015: As I wrote in my comment, you don't actually set the value of interval to the new value, when the encoder position changes. So the blinking interval does not change. You need to use the formula to set the new value to interval. Insert
interval = 60.00 / encoder0Pos * 1000;

before your Serial.print() statements. Also, you need to remove the const keyword at the definition of interval, or you won't be able to change it's value.

Judging from your comments, you misunderstand how variables work. A variable does not save a formula, just a value. a is defined at global scope in your code (outside of any function). That means, that the definition get's executed at the very start of the program. Since encoder0Pos has the value 59 at that time, the value 1016.95 get's assigned to the variable a. This value only ever changes, if you actively assign a new value to that variable (which you never do). The formula is only executed once during the assignment.

60439: <p>ok so I dont actually know anything about coding or electronics outside of being an electrician. This is something i've been working on for about a month.
I may be asking something dumb but here it is.</p>

<p>also i dont know where to put my code so ill put it in the comments (sorry).</p>

<p>so basically I want a visual metronome. I want to plug a control box into the wall, plug a lamp into the control box to blink at a set interval. the box will have a rotary encoder and lcd display to control the beats per minute. to achieve this im gonna use a SSR and some transformers to achieve a variety of voltages for different led lights. but I want to affect a 120v cct to do it all. but I just want to get the code down before I build it so im trying to blink the onboard led on my arduino uno for now.</p>

<p>I have the code, which is 3 different sketches, frankensteined together. probably poorly. 
I added an arithmetic equation to facilitate the metronome timing but I cant transfer that value to the "interval" for the blinking light. </p>

<p>In my serial viewer, the equation works and it gives me the values I desire. I just cant get that into the interval.</p>

<p>the math equation is simple
(60/bpm)1000 = intended interval</p>

<p>example: (60/120)1000 = 500 as the milli interval for the blinking light. 2 blinks per second.</p>

<pre><code>enter code here





// rotary encoder -----------------

int val;
int encoder0PinA = 6;
int encoder0PinB = 7;
int encoder0Pos = 59;
int encoder0PinALast = LOW;
int n = LOW;

// lcd screen ---------------------

     // include the library code:
#include &lt;LiquidCrystal.h&gt;

     // initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


// led blink ----------------------

     // the number of the LED pin
const int ledPin =  LED_BUILTIN;

     // ledState used to set the LED
int ledState = LOW;             

     // will store last time LED was updated
unsigned long previousMillis = 0;      

     // interval at which to blink (milliseconds) --    long interval = ;


// mathssss -----------------------

float a = (60 / encoder0Pos) * 1000;



// on to setup -------------------------------------------------------



void setup() {
      // put your setup code here, to run once:




// rotary encoder ---------------
 pinMode (encoder0PinA, INPUT);
  pinMode (encoder0PinB, INPUT);
  Serial.begin (9600);



  Serial.println ("hi");

// lcd screen -------------------
      // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
      // Print a message to the LCD.
  lcd.print("BeatsPerMinute");

// led blink -------------------
pinMode(ledPin, OUTPUT);

}


// on to loop --------------------------------------------------------
void loop() {
      // put your main code here, to run repeatedly:
      long interval = (60.00 / encoder0Pos) * 1000;

// rotary encoder --------------
  n = digitalRead(encoder0PinA);
  if ((encoder0PinALast == LOW) &amp;&amp; (n == HIGH)) {
    if (digitalRead(encoder0PinB) == LOW) {
      encoder0Pos--;
    } else {
      encoder0Pos++;
    }

     // serial ----------------------------------------------------------------------
  Serial.println ("BPM");
  Serial.println (encoder0Pos);
  Serial.println ("interval");
  Serial.println (interval);
  Serial.println ("intended interval");
  Serial.println (60.00 / encoder0Pos * 1000, 8);
  Serial.println ("----------------");
     // serial done -----------------------------------------------------------------
  }
  encoder0PinALast = n;

  // lcd screen ----------------

       // set the cursor to column 0, line 1
       // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
       // print the number of seconds since reset:
  lcd.print(encoder0Pos);

  // led blink -----------------

    unsigned long currentMillis = millis();

  if (currentMillis - previousMillis &gt;= interval) {
      previousMillis = currentMillis;    
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }


    digitalWrite(ledPin, ledState);

 // serial --------------------


 // done


  }

}
</code></pre>
 42015: <p>As I wrote in my comment, you don't actually set the value of <code>interval</code> to the new value, when the encoder position changes. So the blinking interval does not change. You need to use the formula to set the new value to <code>interval</code>. Insert</p>

<pre><code>interval = 60.00 / encoder0Pos * 1000;
</code></pre>

<p>before your <code>Serial.print()</code> statements. Also, you need to remove the <code>const</code> keyword at the definition of <code>interval</code>, or you won't be able to change it's value.</p>

<hr>

<p>Judging from your comments, you misunderstand how variables work. A variable does not save a formula, just a value. <code>a</code> is defined at global scope in your code (outside of any function). That means, that the definition get's executed at the very start of the program. Since <code>encoder0Pos</code> has the value 59 at that time, the value <code>1016.95</code> get's assigned to the variable <code>a</code>. This value only ever changes, if you actively assign a new value to that variable (which you never do). The formula is only executed once during the assignment.</p>
