daryllqayyimdarplayzgt
Published © CC BY-NC

Control LED speed with pontetiometer!!!!

Control LED with the original pontetometer.

IntermediateShowcase (no instructions)754
Control LED speed with pontetiometer!!!!

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
LED (generic)
LED (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

follow the steps

Code

copy the code and paste

Java
the code is long a little bit sorry.
int potPin = 2;               // Potmeter pin
int ledPin = LED_BUILTIN;     // Builtin LED pin
int potVal = 0;               // Potmeter's value (0 by default)

void setup() {
  Serial.begin(9600);         // Start the serial monitor at 9600 baud
  pinMode(ledPin, OUTPUT);    // Set ledPin as output
}

// The loop() function runs infinitely
void loop() {
  
  potVal = analogRead(potPin);       // Read the analog value of the potmeter (0-1023)
  Serial.println(potVal);            // Write the value to the serial monitor
  
  digitalWrite(LED_BUILTIN, HIGH);   // Turn the built-in LED on
  delay(potVal);                     // Pause for the length of the potval value (0-1023) milliseconds
  
  digitalWrite(LED_BUILTIN, LOW);    // Turn the built-in LED on
  delay(potVal);                     // Pause for the length of the potval value (0-1023) milliseconds
  
}

Credits

daryllqayyim
8 projects • 4 followers
darplayzgt
9 projects • 3 followers

Comments