Reading Potentiometer with Arduino

 

Potentiometer is an another resistor whose resistance value or the value of its resistance can be changed according to our needs. With Arduino, we can see how the value generated by a potentiometer at certain positions. Then we can manipulate to suit our needs.

In this labs we will make a simple test that turned LED with a resistance value is changed by a potentiometer.

Tools needed :

1x Arduino

1x Breadboard
1x Potensiometer
1x Led
5x  Jumper cable

potentiometer(sumber img: arduino.cc)

 

insert code bellow :

 

int potPin = 2;    // nilai inputan analog pada pin2
int ledPin = 13;   // select the pin for the LED (default arduino)
int val = 0;       // nilai resistansi awal

void setup() {
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
}

void loop() {
  val = analogRead(potPin);    // read the value from the sensor
  digitalWrite(ledPin, HIGH);  // turn the ledPin on
  delay(val);                  // stop the program for some time
  digitalWrite(ledPin, LOW);   // turn the ledPin off
  delay(val);                  // stop the program for some time
}

hasil :

IMG_20160729_134439

another reff : https://www.arduino.cc/en/tutorial/potentiometer

 

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s