How do you plan to solve it?
To raise brightness you increase the output on pwm pin from 0 to max of 255.
to dim it you reduce it from 255 to 0;
in 255 steps with a short delay after every step up or down.
for (i=0; i <= 255; i++) {
analogWrite(pwmPin, i);
delay(shortwhile);
}
Read the raw potentiometer on A0,
Use pins 10, 9, 6,5,3
/*Paste your code here*/
int potPin = 0;
int pwmPin[5] = {10, 9, 6, 5, 3};
int pot, poti, period, period_backup, direction;
void setup()
{
int i;
period=0;
period_backup=100; //weird number to start the backup
direction=0; // direction is 0 or 1 for going up or down in brightness
for (i=0; i < 5; i++) {
pinMode(pwmPin[i], OUTPUT);
}
Serial.begin(9600);
}
void ledWaxAndWane(int direction)
{
int wax, wane;
switch(direction) {
case 0:
for (wax=0; wax <= 255; wax++) {
wane= 255-wax;
analogWrite(pwmPin[0], wax);
analogWrite(pwmPin[2], wax);
analogWrite(pwmPin[4], wax);
analogWrite(pwmPin[1], wane);
analogWrite(pwmPin[3], wane);
delay(period);
}
break;
case 1:
for (wax=0; wax <= 255; wax++) {
wane= 255-wax;
analogWrite(pwmPin[0], wane);
analogWrite(pwmPin[2], wane);
analogWrite(pwmPin[4], wane);
analogWrite(pwmPin[1], wax);
analogWrite(pwmPin[3], wax);
delay(period);
}
break;
}
}
void loop()
{
pot = analogRead(potPin);
period= map(pot, 0, 1023, 1, 10) ;
// print only if potentioeter/period is moved
if (period != period_backup) {
Serial.println("");Serial.print("Potentiometer: "); Serial.print(pot);
Serial.print(", Period: "); Serial.println(period);
period_backup = period;
}
direction ^=1;
Serial.println(direction);
ledWaxAndWane(direction);
delay(100);
}
Add video of output (know more)
Add a photo of your hardware showing the output.