Arduino: upravljati servo motorom s potenciometrom
U ovom praktičnom savjetu objašnjavamo kako upravljati servo motorom s potenciometrom pomoću Arduino-a.
Upravljanje servo motorom s potenciometrom - Potrebne komponente
Da biste mogli implementirati ovaj projekt prilagođen početnicima, trebat će vam, naravno, servo motor, Arduino i potenciometar od 10 kΩ. Za povezivanje vam trebaju i krušna ploča i neki skakači.
Arduino: izgraditi krug
- Potenciometar postavite na ploču. Pričvrstite pin na krajnjoj lijevoj strani sa plus trakom. Zatič na desnoj strani spojen je na minus bar. Također priključite srednji pin na Analog 0 na Arduino.
- Crveni kabel servo motora spojite na plus traku, a smeđi kabel na minus bar. Narančasta je spojena na iglu 9 na arduinu.
- Napokon, sve što trebate učiniti je spojiti minus bar na zemlju i plus traku na 5V pin na Arduino.
Arduino: upravljački servo motor s potenciometrom - kod
Ispod smo vam pružili jednostavan kod koji lako možete učitati na Arduino.
- #include
- Servo myservo;
- int pot = 0;
- int vrijednost;
- poništavanje postave () {
- myservo.attach (9);
- }
- void petlja () {
- vrijednost = analogRead (pot);
- vrijednost = karta (vrijednost, 0, 1023, 0, 180);
- myservo.write (vrijednost);
- kašnjenje (15);
- }
U sljedećem praktičnom savjetu pokazat ćemo vam kako upravljati LCD-om pomoću Arduino-a.