
// The setup() method runs once, when the sketch starts


int ledPinA =  7;    //output pin (led)
int ledPinB =  6;    //output pin (speaker)

int sensorPinA = 3;    // input pin for the potentiometerA
int sensorPinB = 4;    // input pin for the potentiometerB

int sensorValueA = 0;  //analog valueA
int sensorValueB = 0;  //analog valueB

void setup()   {                
  Serial.begin(9600);
  // initialize the digital pin as an output:
  pinMode(ledPinA, OUTPUT);     
  pinMode(ledPinB, OUTPUT);     
}

// the loop() method runs over and over again,
// as long as the Arduino has power

int counterA=0;
int counterB=0;

int boolA=0;
int boolB=0;

void loop()                     
{

   
  sensorValueA = analogRead(sensorPinA);    
  sensorValueB = analogRead(sensorPinB);    

  digitalWrite(ledPinA, HIGH);  
  Serial.println(sensorValueA);
  Serial.println(sensorValueB);

  counterA++;
  counterB++;
 
  if ((counterA>sensorValueA) && (boolA==0))
  { boolA=1; counterA=0; }  

  if ((counterA>sensorValueA) && (boolA==1))
  { boolA=0; counterA=0; }  

  if ((counterB>sensorValueB) && (boolB==0))
  { boolB=1; counterB=0; }  

  if ((counterB>sensorValueB) && (boolB==1))
  { boolB=0; counterB=0; }  

  digitalWrite(ledPinA, boolA);  
  digitalWrite(ledPinB, boolB);  
  
  if (counterA>1000) { counterA=0; }
  if (counterB>1000) { counterB=0; }

}

