Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
620 B
1
Indexable
Never
int value = 0;
int NUMBER_LED = 6;
int PIN_LED_FIRST = 2;
void setup()
{
  Serial.begin(115200);
  pinMode(A0, INPUT);
  for (int i = PIN_LED_FIRST; i < PIN_LED_FIRST + NUMBER_LED; i++)
  {
    pinMode(i, OUTPUT);
  }
}

void loop()
{
  // value = analogRead(A0);
  value = 1024.0;
  int numberPin = int(value / 1024.0 * (NUMBER_LED+1));
  for (int i = PIN_LED_FIRST; i < PIN_LED_FIRST + numberPin; i++)
  {
    digitalWrite(i, 1);
  }
  for (int i = numberPin; i < PIN_LED_FIRST + NUMBER_LED; i++)
  {
    digitalWrite(i, 0);
  }
  Serial.print("Value of A0: ");
  Serial.println(value);
}
Leave a Comment