Welcome, Guest
Username: Password: Remember me

TOPIC: Time Manipulator Firmware

Time Manipulator Firmware 10 months 2 weeks ago #1657

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Moderator
  • Posts: 695
  • Thank you received: 146
  • Karma: 42
This is the code that is loaded in all the Time Manipulator pedals, it has 2 main functionalities:
  1. It can debug the pedal: when bridging the R24 DEBUG resistor, the pedal goes into debugging mode. Check the Time Manipulator Assembly Guide for more information.
  2. It contains 9 basic effects:
    • 1. Short Delay
    • 2. Delay
    • 3. Echo
    • 4. Reverb
    • 5. Tap Echo
    • 6. Chorus
    • 7. Telegraph
    • 8. Accelerator
    • 9. Psycho Echo

sticker_effects.png


In this forum, you can find independent topics of each of these effects, in case you need more info.
Have a look at the Time Manipulator Instructions to learn how to interact with the pedal:
Although all the Time Manipulators are loaded with this code, you can modify it, upload new codes or try your own ideas. Have a look to the "How to Reprogram the Time Manipulator" topic.

The code is long as a result of constant evolution and small improvements.
These are some of the features that the firmware includes:

1. Initializing the pedal: Every time you start the pedal, the "pedal_init();" function will recover from EEPROM memory the effect and the master encoder position you were using last time.

2. The Master encoder has endless turns, so it's not easy to know when the delay time is set to minimum, mid or maximum position. To solve this, in "Normal Mode", the green LEDs that look like the cat eyes "GREEN - GREEN" blink:
ORANGE - GREEN: master in minimum position.
ORANGE - ORANGE : master in min position.
GREEN - ORANGE: master in max position.
Is not easy to understand but once you turn the master encoder and see the cat eyes blinking is easy to understand the position.
In the code, you can see this feature here:
//the switch function below lights the eyes to indicate low, medium and high position of the encoder
  switch (ENC_counter)
  {
  case(50): {digitalWrite(LED1_R,HIGH);  digitalWrite(LED2_R,LOW); break;}
  case(150):{digitalWrite(LED1_R,HIGH);  digitalWrite(LED2_R,HIGH);break;}
  case(230):{digitalWrite(LED1_R,LOW);  digitalWrite(LED2_R,HIGH);break;}
  default:  {digitalWrite(LED1_R,LOW);  digitalWrite(LED2_R,LOW);} 
  }

3. Divisions You will find many times in the code lines like "ENC_counter>>1" that is equal to "ENC_counter/2" or if you have "ENC_counter>>2" is equal to "ENC_counter/4" (more info forum.arduino.cc/index.php?topic=277509.0)

4. Extensive using of millis(); in the code the delay(); function cannot be used most of the times because during its execution it freezes the microcontroller and other important tasks (like reading the encoder) are ignored. To fix that the millis(); function is used to create delays. more info here: www.arduino.cc/en/tutorial/BlinkWithoutDelay





The complete Time Manipulator V1.0 code looks like this:
//This is the V1.0 firmware for the Time Manipulator guitar pedal
//more info at www.electrosmash.com/time-manipulator
 
 #include <EEPROM.h> 

// Pin Definitions: 
//Delay PWM signals (U1)
#define DELAY1 10
#define DELAY2 9

//Switch (U4)
#define SWA 3
#define SWB 14
#define SWC 2
#define SWD 4 

//LED (D2 and D3)
#define LED1_G 1 
#define LED1_R 0
#define LED2_G 5
#define LED2_R 6

//Encoder (ENC1) 
#define ENC_A     16
#define ENC_B     18
#define ENC_GND   17
#define ENC_PUSH  19

//Footswitches
#define BYPASS_DETECT 8
#define TAP_DETECT    15
#define DEBUG_MODE    7

//Effects Definitions
#define SHORT_DELAY 1   //  0 G
#define DELAY       2   //  G 0
#define ECHO        3   //  G G
#define REVERB      4   //  0 R
#define TAP         5   //  R 0
#define CHORUS      6   //  R R
#define TELEGRAPH   7   //  G R
#define ACCELERATOR 8   //  R G
#define PSYCHO      9  //   N N

//Time to ms conversion table
 int delay_conv[]={ 230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,
 230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,
 230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,
 230,230,230,230,230,230,230,230,230,230,230,
 230,229,228,227,226,224,223,222,221,220,219,218,217,216,214,213,212,211,210,209,208,207,206,205,204,203,202,201,200,198,196,194,192,190,189,188,187,186,184,183,182,181,180,179,178,176,175,174,
 173,171,170,169,168,168,167,166,165,164,163,163,162,161,160,159,158,157,156,155,155,154,153,152,151,150,149,148,148,147,146,145,144,143,143,142,141,140,139,139,138,137,137,136,135,135,134,133,133,132,131,131,130,
 129,129,128,128,127,127,126,126,125,124,124,123,123,122,122,121,121,120,120,119,119,118,118,117,117,116,116,115,115,114,114,113,113,112,112,111,111,110,110,109,109,108,108,108,107,107,106,106,105,105,105,104,104,
 103,103,103,102,102,101,101,100,100,100,99,99,99,98,98,98,97,97,97,96,96,96,95,95,94,94,94,93,93,93,92,92,92,91,91,91,90,90,90,89,89,89,89,88,88,88,88,87,87,87,86,86,86,86,85,85,85,84,84,84,84,83,83,83,83,82,82,
 82,81,81,81,81,80,80,80,80,79,79,79,79,79,78,78,78,78,78,77,77,77,77,76,76,76,76,76,75,75,75,75,75,74,74,74,74,74,73,73,73,73,73,72,72,72,72,71,71,71,71,71,70,70,70,70,70,70,69,69,69,69,69,69,68,68,68,68,68,68,68,
 67,67,67,67,67,67,66,66,66,66,66,66,66,65,65,65,65,65,65,64,64,64,64,64,64,64,63,63,63,63,63,63,62,62,62,62,62,62,62,61,61,61,61,61,61,60,60,60,60,60,60,60,60,59,59,59,59,59,59,59,59,58,58,58,58,58,58,58,58,58,57,
 57,57,57,57,57,57,57,57,56,56,56,56,56,56,56,56,55,55,55,55,55,55,55,55,55,54,54,54,54,54,54,54,54,53,53,53,53,53,53,53,53,53,52,52,52,52,52,52,52,52,52,51,51,51,51,51,51,51,51,50,50,50,50,50,50,50,50,50,50,
 50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50};
 
//VARIABLES
unsigned int ENC_counter = 100; 
int ENC_aState;
int ENC_aLastState;  
int ENC_aState_selection=0;
int ENC_aLastState_selection=0;
 
//DEBUG_MODE variables
int delay_variable = 0;
 
unsigned long delay_currentMillis, delay_previousMillis = 0;  
 
 //things to delete
int direction_up=0;
byte effect;
unsigned long currentMillis,previousMillis = 0; 
unsigned long startTime;
unsigned long endTime;
unsigned long duration=200;
byte timerRunning=0;
int psycho_counter = 0;
int chorus_counter = 0;
int accelerator_counter=0;
int doubler_counter = 0;
int first_time=0;
byte effect_status=HIGH;
 
void selection_mode(void);
void pedal_init(void);
void set_audio_relays(byte);
void set_effect_leds (byte effect);
void debug_mode_funtion(void);  
 
// the setup function runs once when you press reset or power the board
void setup() {
//set the pins  
pinMode(DELAY1, OUTPUT);
pinMode(DELAY2, OUTPUT);
pinMode(SWA, OUTPUT);
pinMode(SWB, OUTPUT);
pinMode(SWC, OUTPUT);
pinMode(SWD, OUTPUT);
pinMode(LED1_G, OUTPUT);
pinMode(LED1_R, OUTPUT);
pinMode(LED2_G, OUTPUT);
pinMode(LED2_R, OUTPUT);
pinMode(ENC_A, INPUT_PULLUP);
pinMode(ENC_B, INPUT_PULLUP);
pinMode(ENC_GND, OUTPUT);
pinMode(ENC_PUSH, INPUT_PULLUP);
pinMode(BYPASS_DETECT, INPUT_PULLUP);
pinMode(TAP_DETECT, INPUT_PULLUP);
pinMode(DEBUG_MODE, INPUT_PULLUP);
 
// initialize all the pins
analogWrite(DELAY1, 100);
analogWrite(DELAY2, 100);
digitalWrite(SWA, LOW);
digitalWrite(SWB, LOW);
digitalWrite(SWC, LOW);
digitalWrite(SWD, LOW);
analogWrite(LED1_G, 0);
analogWrite(LED1_R, 0);
analogWrite(LED2_G, 0);
analogWrite(LED2_R, 0);
 
analogWrite(DELAY1, ENC_counter);
analogWrite(DELAY2, ENC_counter);
 
digitalWrite(LED1_G,LOW);
digitalWrite(LED2_G,HIGH);
 
ENC_aLastState = digitalRead(ENC_A);  
pedal_init();
}
 
// the loop function runs over and over again forever
void loop() 
{
//detect if the effect is in DEBUG MODE
while((digitalRead(DEBUG_MODE) == LOW)) 
  {
    debug_mode_funtion();  
  }  
 
 
effect_status=HIGH;
while((digitalRead(BYPASS_DETECT) == LOW)) //detect if the effect is on or off 
  {//going into bypass mode
  digitalWrite(LED1_R,LOW);digitalWrite(LED2_R,LOW);digitalWrite(LED1_G,LOW);digitalWrite(LED2_G,LOW); 
  effect_status=LOW;
  }  
 
if (effect_status==LOW) //waking up from bypass mode 
  { 
    effect_status=HIGH;
    pedal_init();
  }
 
//go to selection if encoder is pushed
  if ( digitalRead(ENC_PUSH)== LOW)
  {
    delay(200);//debouncing
    if ( digitalRead(ENC_PUSH)== HIGH)  
    selection_mode();
  }
 
 ENC_aState = digitalRead(ENC_A); // Reads the "current" state of the outputA
   if (ENC_aState != ENC_aLastState)
   {    
     if (digitalRead(ENC_B) != ENC_aState) 
          {if(ENC_counter>50)ENC_counter-=5;}
     else 
          {if(ENC_counter<230)ENC_counter+=5;}
 
 //the switch function below lights the eyes to indicate low, medium and high position of the encoder
  switch (ENC_counter)
  {
  case(50): {digitalWrite(LED1_R,HIGH);  digitalWrite(LED2_R,LOW); break;}
  case(150):{digitalWrite(LED1_R,HIGH);  digitalWrite(LED2_R,HIGH);break;}
  case(230):{digitalWrite(LED1_R,LOW);  digitalWrite(LED2_R,HIGH);break;}
  default:  {digitalWrite(LED1_R,LOW);  digitalWrite(LED2_R,LOW);} 
  }
   } 
ENC_aLastState = ENC_aState; // Updates the previous state of the outputA with the current state
 
 
switch(effect)
  {
case(SHORT_DELAY):
      {
        digitalWrite(LED1_G,HIGH);digitalWrite(LED2_G,HIGH);
        digitalWrite(SWA, HIGH);digitalWrite(SWB, LOW);digitalWrite(SWC, HIGH);digitalWrite(SWD, LOW);
        analogWrite(DELAY1, ENC_counter);
        analogWrite(DELAY2, ENC_counter);
        break; 
      }
 
case(DELAY):
      {
        digitalWrite(LED1_G,HIGH);digitalWrite(LED2_G,HIGH);
        digitalWrite(SWA, LOW);digitalWrite(SWB, HIGH);digitalWrite(SWC, HIGH);digitalWrite(SWD, LOW);
        analogWrite(DELAY1, ENC_counter);
        analogWrite(DELAY2, ENC_counter);
        break; 
      }
 
case(ECHO):
      {
        digitalWrite(LED1_G,HIGH);digitalWrite(LED2_G,HIGH);
        digitalWrite(SWA, HIGH);digitalWrite(SWB, HIGH);digitalWrite(SWC, HIGH);digitalWrite(SWD, HIGH);
        analogWrite(DELAY1, ENC_counter);
        analogWrite(DELAY2, ENC_counter);
        break; 
      }
 
case(REVERB):
        {
        digitalWrite(LED1_G,HIGH);digitalWrite(LED2_G,HIGH);
        digitalWrite(SWA, HIGH);digitalWrite(SWB, LOW);digitalWrite(SWC, HIGH);digitalWrite(SWD, HIGH);
        analogWrite(DELAY2, 220-(ENC_counter>>1));//one delay is 1/2 the other
        analogWrite(DELAY1, 220);
        break; 
        }
 
case(TAP):
        {
         digitalWrite(SWA, LOW);digitalWrite(SWB, HIGH);digitalWrite(SWC, HIGH);digitalWrite(SWD, LOW);
         if (timerRunning == 0 && digitalRead(TAP_DETECT) == LOW)
            { // button pressed & timer not running already  
              startTime = millis();
              timerRunning = 1;
              delay(200);//debouncing  
            }
          if (timerRunning == 1 && digitalRead(TAP_DETECT) == LOW)
            { // timer running, button released
              endTime = millis();
              timerRunning = 0;
              duration = endTime - startTime;
            }
            currentMillis = millis();
            if ( currentMillis - previousMillis >= duration) 
            { 
              // save the last time you blinked the LED
              previousMillis = currentMillis;
              // if the LED is off turn it on and vice-versa:
              digitalWrite(LED1_R,!digitalRead(LED1_R));
              digitalWrite(LED2_R,!digitalRead(LED2_R));
            }   
            if (duration<600)
            {       
            analogWrite(DELAY1, delay_conv[duration]);
            analogWrite(DELAY2, delay_conv[duration]);
            }
              else if (duration<1200)
              {       
                analogWrite(DELAY1, delay_conv[duration>>1]);
                analogWrite(DELAY2, delay_conv[duration>>1]);
              }
                else if (duration<2400)
                  {
                    analogWrite(DELAY1, delay_conv[duration>>2]);
                    analogWrite(DELAY2, delay_conv[duration>>2]);
                  }
                  else 
                    {
                      analogWrite(DELAY1, 50);
                      analogWrite(DELAY2, 50);
                    }                                   
         break; 
        }        
 
case(CHORUS):
        {
          digitalWrite(SWA, HIGH);digitalWrite(SWB, LOW);digitalWrite(SWD, HIGH);
          digitalWrite(SWC,!digitalRead(TAP_DETECT));
 
  if (direction_up==1)
          {
           digitalWrite(LED1_R,HIGH);digitalWrite(LED2_R,HIGH);digitalWrite(LED1_G,LOW);digitalWrite(LED2_G,LOW);
            if (chorus_counter>230) {chorus_counter=230; direction_up=0;}
            //delay created by millis();
            delay_currentMillis = millis();
           if (delay_currentMillis - delay_previousMillis >= (30 + ENC_counter>>1)) 
            {
              delay_previousMillis = delay_currentMillis;
               chorus_counter++; //if too fast try divider 
            }           
          }
            else 
            { 
              digitalWrite(LED1_R,LOW);digitalWrite(LED2_R,LOW);digitalWrite(LED1_G,HIGH);digitalWrite(LED2_G,HIGH);             
              if (chorus_counter<210) {chorus_counter=210;direction_up=1;}
              //delay created by millis();
              delay_currentMillis = millis();
           if (delay_currentMillis - delay_previousMillis >= (30 + ENC_counter>>1)) 
            {
              delay_previousMillis = delay_currentMillis;
              chorus_counter--; //if too fast try divider 
            }
             }          
        analogWrite(DELAY1, chorus_counter);
        analogWrite(DELAY2, 440 - chorus_counter);
        break; 
        }
 
case(TELEGRAPH):
        {
          digitalWrite(SWA, LOW);digitalWrite(SWB, LOW);digitalWrite(SWD, LOW);
          digitalWrite(LED1_R,!digitalRead(TAP_DETECT));
          digitalWrite(LED2_R,!digitalRead(TAP_DETECT));
          digitalWrite(SWC,!digitalRead(TAP_DETECT));
          break; 
        }    
 
case(ACCELERATOR):
        {
       digitalWrite(SWA, LOW);digitalWrite(SWB, HIGH);digitalWrite(SWC, HIGH);digitalWrite(SWD, LOW);
          if (first_time==1){accelerator_counter=120;first_time=0;}// 120 by default
//if TAP footswitch is pushed, reduce the delay time (ACCELERATOR_counter)
if ((digitalRead(TAP_DETECT) == LOW) && (accelerator_counter>=50)) 
  {  
    digitalWrite(LED1_G,LOW);digitalWrite(LED2_G,LOW);
    digitalWrite(LED1_R,HIGH);digitalWrite(LED2_R,HIGH);
    //the 6 lines below introduce a delay (40ms), so the delay time (ACCELERATOR_counter) is not reduced too fast.  
    delay_currentMillis = millis();
    if (delay_currentMillis - delay_previousMillis >= 40) 
    {
      delay_previousMillis = delay_currentMillis;
      accelerator_counter--;
    }
  }  
 
//return to the original position if nothing happens.
else if (accelerator_counter <= ENC_counter) 
  {
    digitalWrite(LED1_G,LOW);digitalWrite(LED2_G,LOW);
    digitalWrite(LED1_R,HIGH);digitalWrite(LED2_R,HIGH);
    delay_currentMillis = millis();
    if (delay_currentMillis - delay_previousMillis >= 60) 
    {
      delay_previousMillis = delay_currentMillis;
      accelerator_counter++;
    }
  }    
 
else 
  {
  digitalWrite(LED1_G,HIGH);digitalWrite(LED2_G,HIGH);
  digitalWrite(LED1_R,LOW);digitalWrite(LED2_R,LOW);
  }
 
//update the delay time    
analogWrite(DELAY1, accelerator_counter);
analogWrite(DELAY2, accelerator_counter);
          break; 
        }
 
case(PSYCHO):
        {
          digitalWrite(SWA, HIGH);digitalWrite(SWB, HIGH);digitalWrite(SWC, HIGH);digitalWrite(SWD, HIGH);
if (direction_up==1)
  {
    digitalWrite(LED1_R,LOW);digitalWrite(LED2_R,HIGH);digitalWrite(LED1_G,HIGH);digitalWrite(LED2_G,LOW); 
    psycho_counter++; //if too fast try divider 
    if (psycho_counter>220) {psycho_counter=220; direction_up=0;}
    delay(ENC_counter>>1);
  }
else 
  {
    digitalWrite(LED1_R,HIGH);digitalWrite(LED2_R,LOW);digitalWrite(LED1_G,LOW);digitalWrite(LED2_G,HIGH);
    psycho_counter--; //if too fast try divider 
    if (psycho_counter<50) {psycho_counter=20;direction_up=1;}
    delay(ENC_counter>>1);
  }            
if ((psycho_counter>>1)>50)analogWrite(DELAY1, psycho_counter>>1); else analogWrite(DELAY1, 50);
analogWrite(DELAY2, 270 - psycho_counter);
        break; 
        }     
    }
}
 
 
void pedal_init(void) //read important values from EEPROM
{
effect= EEPROM.read(0);
if (effect>9)
{effect=0;EEPROM.write(0, effect);}
 
ENC_counter= EEPROM.read(1);
if (((ENC_counter<20)||(ENC_counter>230))||((ENC_counter%5)!=0)) 
{ENC_counter=100;EEPROM.write(1, ENC_counter);}
}
 
void selection_mode(void)
{
  int slow_up=0;
  int slow_down=0;  
  ENC_aLastState_selection = digitalRead(ENC_A);
  digitalWrite(LED1_G,LOW); digitalWrite(LED2_G,LOW);
while(( digitalRead(ENC_PUSH)== HIGH)||(digitalRead(BYPASS_DETECT) == LOW))
 {
 
  while((digitalRead(BYPASS_DETECT) == LOW)) //detect if the effect is on or off 
  {//going into bypass mode
  digitalWrite(LED1_R,LOW);digitalWrite(LED2_R,LOW);digitalWrite(LED1_G,LOW);digitalWrite(LED2_G,LOW); 
  effect_status=LOW;
  } 
 
 ENC_aState_selection = digitalRead(ENC_A); // Reads the "current" state of the outputA
   if (ENC_aState_selection != ENC_aLastState_selection)
   {      
     if (digitalRead(ENC_B) != ENC_aState_selection) 
     { 
      if (effect<9) slow_up++; if (slow_up>2) {effect ++; slow_up=0;}
 
     } 
     else 
     {
      if (effect>1) slow_down++; if (slow_down>2) {effect --; slow_down=0;}
     }
    set_effect_leds(effect);
   } 
   ENC_aLastState_selection = ENC_aState_selection; // Updates the previous state of the outputA with the current state
   set_effect_leds(effect);
}
 
  delay(500);//debouncing 
  digitalWrite(LED1_G,HIGH);
  digitalWrite(LED2_G,HIGH);
 
//save important values in EEPROM
EEPROM.write(0, effect);
EEPROM.write(1, ENC_counter);
 
//set_audio_relays(effect);
digitalWrite(SWA, LOW);digitalWrite(SWB, LOW);digitalWrite(SWC, LOW);digitalWrite(SWD, LOW);  
return;   
}
 
void set_effect_leds (byte effect)
  {
    if     (effect==SHORT_DELAY)  {digitalWrite(LED1_G, HIGH);digitalWrite(LED2_G,LOW);digitalWrite(LED1_R,LOW);  digitalWrite(LED2_R,LOW);}
    else if (effect==DELAY)       {digitalWrite(LED2_G, HIGH);digitalWrite(LED1_G,LOW);digitalWrite(LED1_R,LOW);  digitalWrite(LED2_R,LOW);}
    else if (effect==ECHO)        {digitalWrite(LED1_G, HIGH); digitalWrite(LED2_G, HIGH);digitalWrite(LED1_R,LOW);  digitalWrite(LED2_R,LOW);}
    else if (effect==REVERB)      {digitalWrite(LED1_R, HIGH);digitalWrite(LED1_G,LOW);  digitalWrite(LED2_G,LOW); digitalWrite(LED2_R,LOW);}
    else if (effect==TAP)         {digitalWrite(LED2_R, HIGH);digitalWrite(LED1_G,LOW);  digitalWrite(LED2_G,LOW); digitalWrite(LED1_R,LOW);}
    else if (effect==CHORUS)      {digitalWrite(LED1_R, HIGH);digitalWrite(LED2_R, HIGH);digitalWrite(LED1_G,LOW);  digitalWrite(LED2_G,LOW);}
    else if (effect==TELEGRAPH)   {digitalWrite(LED1_R, HIGH);digitalWrite(LED2_G, HIGH);digitalWrite(LED1_G,LOW);digitalWrite(LED2_R,LOW);}
    else if (effect==ACCELERATOR) {digitalWrite(LED1_G, HIGH);digitalWrite(LED2_R, HIGH);digitalWrite(LED2_G,LOW); digitalWrite(LED1_R,LOW);}
    else if (effect==PSYCHO)      {digitalWrite(LED1_G, HIGH);digitalWrite(LED2_G, HIGH);digitalWrite(LED1_R, HIGH);digitalWrite(LED2_R, HIGH);}  
}
 
void debug_mode_funtion(void)
{          
  delay(100);
  delay_variable+=100;
  if (delay_variable>4000)delay_variable=0;
 
  if(delay_variable<2000)
  {
  analogWrite(DELAY1, delay_variable>>3); //every 2s
  analogWrite(DELAY2, delay_variable>>3);
  }
  else
  {
  analogWrite(DELAY1, 255 - ((delay_variable-2000)>>3)); //every 2s
  analogWrite(DELAY2, 255 - ((delay_variable-2000)>>3));
  }
 
 
  if(digitalRead(TAP_DETECT) == HIGH)
  {
    if (delay_variable<2000)
      {digitalWrite(SWA, LOW); digitalWrite(SWB, LOW); digitalWrite(SWC, LOW); digitalWrite(SWD, LOW);}
    else  
      {digitalWrite(SWA, HIGH);digitalWrite(SWB, HIGH);digitalWrite(SWC, HIGH);digitalWrite(SWD, HIGH);} 
  }
  if(digitalRead(TAP_DETECT) == LOW)
  {
    if (delay_variable<1000)
      {digitalWrite(SWA, LOW); digitalWrite(SWB, LOW); digitalWrite(SWC, LOW); digitalWrite(SWD, LOW);} 
    else if (delay_variable<2000)
      {digitalWrite(SWA, HIGH);digitalWrite(SWB, HIGH);digitalWrite(SWC, HIGH);digitalWrite(SWD, HIGH);} 
    else if (delay_variable<3000)
      {digitalWrite(SWA, LOW); digitalWrite(SWB, LOW); digitalWrite(SWC, LOW); digitalWrite(SWD, LOW);} 
    else
      {digitalWrite(SWA, HIGH);digitalWrite(SWB, HIGH);digitalWrite(SWC, HIGH);digitalWrite(SWD, HIGH);}
  }
 
  if(digitalRead(BYPASS_DETECT) == HIGH)
  {
    if (delay_variable<1500)
      {digitalWrite(LED1_G,LOW); digitalWrite(LED2_G,LOW); digitalWrite(LED1_R,LOW); digitalWrite(LED2_R,LOW);} //OFF
    else if (delay_variable<3000)
      {digitalWrite(LED1_G,HIGH);digitalWrite(LED2_G,HIGH);digitalWrite(LED1_R,LOW); digitalWrite(LED2_R,LOW);} //GREEN
    else
      {digitalWrite(LED1_G,LOW); digitalWrite(LED2_G,LOW); digitalWrite(LED1_R,HIGH);digitalWrite(LED2_R,HIGH);} //OFF
  }  
 
  if(digitalRead(BYPASS_DETECT) == LOW)
  {
    if (delay_variable<750)
      {digitalWrite(LED1_G,LOW); digitalWrite(LED2_G,LOW); digitalWrite(LED1_R,LOW); digitalWrite(LED2_R,LOW);} //OFF 
    else if (delay_variable<1500)
      {digitalWrite(LED1_G,HIGH);digitalWrite(LED2_G,HIGH);digitalWrite(LED1_R,LOW); digitalWrite(LED2_R,LOW);} //GREEN
    else if (delay_variable<2250)
      {digitalWrite(LED1_G,LOW); digitalWrite(LED2_G,LOW); digitalWrite(LED1_R,HIGH);digitalWrite(LED2_R,HIGH);} //OFF
    else if (delay_variable<3000)
      {digitalWrite(LED1_G,LOW); digitalWrite(LED2_G,LOW); digitalWrite(LED1_R,LOW); digitalWrite(LED2_R,LOW);} //OFF
    else if (delay_variable<3500)
      {digitalWrite(LED1_G,HIGH);digitalWrite(LED2_G,HIGH);digitalWrite(LED1_R,LOW); digitalWrite(LED2_R,LOW);} //GREEN
    else 
      {digitalWrite(LED1_G,LOW); digitalWrite(LED2_G,LOW); digitalWrite(LED1_R,HIGH);digitalWrite(LED2_R,HIGH);} //OFF
  } 
}


File Attachment:

File Name: Time-Manipulator-Firmware_V1.0.zip
File Size: 4 KB
Last Edit: 9 months 3 weeks ago by Ray.
The administrator has disabled public write access.
Time to create page: 0.316 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio