Monday

Code

I have been looking into the relevant coding for me to control both the speaker balance and the lighting. For the sake of ease I have made the decision to use two arduino's.

Arduino 1 will be controlling the speaker balance. I will attach a servo to the balance pot on an amplifier. For this I will need to use careful timing that is relevant to the soundtrack to flip the balance from left to right at the suitable moment.

The preliminary code, which I have tested, and works, is as follows:



#include  

Servo myservo;  // create servo 
                
int pos = 0;    // variable to store the servo position 

void setup() 

  myservo.attach(9);  // attaches the servo to pin 9 



void loop() 

  for(pos = 0; pos < 180; pos += 3)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 3 degrees 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(5);                       // takes 5ms to get there
  }
  {
    
delay (5000);    // waits 5 seconds (this will be altered accordingly)
  } 
  for(pos = 180; pos>=1; pos-=3)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(5);                       // waits 5ms to get there
  } 
  {
    delay(5000); // waits 5 seconds (this will be altered accordingly)
  }


This code can obviously be altered to match the timing of the soundtrack on the reel to reel player.

Arduino 2

No comments:

Post a Comment