All submissions

Seesaw Effect Using LEDs

Solving Approach:

How do you plan to solve it?

 

 

Code

/*Paste your code here*/

#define LED_1 3
#define LED_2 5 
#define LED_3 6
#define LED_4 9
#define LED_5 10

#define POT_PIN A0

uint8_t pin_arr[5] = {LED_1, LED_2, LED_3, LED_4, LED_5};
uint8_t w[5] = {1,2,3,4,5};
uint8_t value_arr[5];
int pot_value=0;
int mapped_value = 0;

void setup() {
  // put your setup code here, to run once:
  for(int i=0;i<5;i++)
  {
    pinMode(pin_arr[i],OUTPUT);
  }

}

void loop() {
  // put your main code here, to run repeatedly:
  pot_value = analogRead(POT_PIN);
  
  value_arr[0] = map(pot_value,3,1023,0,255);
  value_arr[1] = map(pot_value,3,1023,63,127);
  value_arr[2] = 127;
  value_arr[3] = map(pot_value,3,1023,191,63);
  value_arr[4] = map(pot_value,3,1023,255,0);



  for(int i=0;i<5; i++)
  {
    analogWrite(pin_arr[i],value_arr[i]);
  
  }

  delay(50);

}


 

Output

Video

Add video of output (know more)

Photo of Output

Add a photo of your hardware showing the output.

 

 

 

 

Submit Your Solution

Note: Once submitted, your solution goes public, helping others learn from your approach!