0Pricing
Arduino & IoT Academy · Ders

Düğmeyle Denetlenen Servo

Servoyu bir potansiyometreyle yönlendirin.

Düğmeyle Denetlenen Servo, CoddyKit'te ücretsiz bir Arduino & IoT Academy dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Arduino & IoT Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Arduino & IoT Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Steer with a Knob

Time to take control by hand. Turn a potentiometer and the servo follows in real time, like a tiny steering wheel. 🎛️

The Plan

The idea is simple: read the knob, convert that number into an angle, and write it to the servo, over and over inside loop().

Read the Knob

Use analogRead() on the pot's pin. It gives back a number from 0 to 1023 that follows how far you've turned the knob.

int val = analogRead(A0);

The Range Mismatch

The knob speaks 0 to 1023, but the servo only understands 0 to 180. You need to convert between those two scales.

map() to the Rescue

The map() function rescales a number from one range into another. It's the perfect bridge from knob units to servo degrees.

int angle = map(val, 0, 1023, 0, 180);

Send It to the Servo

Now feed that mapped angle straight into write(). The servo snaps to whatever position your knob is pointing at.

myServo.write(angle);

The Whole Loop

Read, map, write: stack those three lines in loop() and the servo tracks your knob continuously.

void loop() {
  int val = analogRead(A0);
  int angle = map(val, 0, 1023, 0, 180);
  myServo.write(angle);
}

Let It Settle

Add a tiny delay() at the end of the loop. It gives the servo a moment to reach each position and smooths out the motion.

delay(15);

Wire the Pot

The potentiometer's outer pins go to 5V and ground, and the middle wiper pin goes to analog pin A0. That gives a clean sweep of voltage.

Tame the Jitter

Analog readings wobble a little, so the servo may jitter. Reading several times and averaging, or ignoring tiny changes, calms it down.

Flip the Direction

Want the servo to turn the opposite way? Just swap the map output to go from 180 to 0 instead of 0 to 180.

int angle = map(val, 0, 1023, 180, 0);

Quick Check

Let's connect the knob reading to a servo angle.

Recap

Read the pot, map 0 to 1023 into 0 to 180, then write that angle each loop. Now your hand directly steers the servo. 🙌

Sıkça Sorulan Sorular

“Düğmeyle Denetlenen Servo” dersi ücretsiz mi?

Evet — “Düğmeyle Denetlenen Servo” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Arduino & IoT Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Arduino & IoT Academy kursu toplamda 4 dersten oluşur.

“Düğmeyle Denetlenen Servo” dersinde ne öğreneceğim?

Servoyu bir potansiyometreyle yönlendirin. Arduino & IoT Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Arduino & IoT Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Arduino & IoT Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.

“Düğmeyle Denetlenen Servo” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Arduino & IoT Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Arduino & IoT Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Servo Açısını Nasıl Bilir
  2. Servo Kütüphanesi ve attach
  3. 0'dan 180'e Tarayın
  4. Düğmeyle Denetlenen Servo
← Arduino & IoT Academy Sayfasına Dön