This tutorial is part of: Servo Motors ya mosala
Ba vidéos nionso oyo etali ba servo moteurs oyo ezali na boyokani, etangami awa. Ba liens ya ba vidéos misusu ezali na se ya article oyo.
Kokamba ya Servo na Potentiomètre mpe LCD1602 na kosalela Arduino
void setup() {
lcd.begin(16, 2);
myservo.attach(9); // abɔti servo na pin 9 na objet servo
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Robojax Servo Knob");
delay(2000);
}void loop() {
val = analogRead(potpin); // esengaka motu ya potentiomètre
angle = map(val, 0, 1023, 0, 180); // komeka yango mpo na kosalela na servo
myservo.write(angle); // esengaka esika ya servo kolanda na motu oyo esili komekama
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Motu ya Pot.:");
lcd.setCursor(11, 0);
lcd.print(val);
lcd.setCursor(0, 1);
lcd.print("Angle :");
lcd.setCursor(11, 1);
lcd.print(angle);
delay(500);
}
Loop oyo esengaka motu ya potentiomètre, akomisi yango na angle oyo ekokani mpo na servo, mpe abongisaka eloko ya LCD na motu ya potentiomètre mpe angle ya servo. delay(500) na suka ya loop epekisaka ete eloko ya LCD ebongisama na lombangu mingi te.
Elakiseli / Nini Okokanela
Ntango okotisa nguya na système, LCD ekolakisa "Robojax Servo Knob" mpo na secondes 2, mpe sima motu ya potentiomètre mpe angle ya servo. Ntango okobalola potentiomètre, angle ya servo ekobongwana kolanda yango, mpe motu ya sika ya potentiomètre ekomonana na LCD. Soki omoni likambo oyo esengeli te, lokola servo kotambola na nzela ya mabe, tala ba connexions ya potentiomètre mpe servo (na vidéo na 10:00).
This tutorial is part of: Servo Motors ya mosala
- Kokamba ya Servo na Mabutu ya Kobenda na Arduino
- Control a Servo Motor with a Push Button: Move Servo and Return SPB-1
- Control a Servo Motor with a Push Button: Move Servo in One Direction SPB-2
- Controlling a Servo Motor with a Push Button: Move Servo While Button Is Pressed (SPB-3)
- Koyamba servo na potentiometer na Arduino
- Controlling Servo Motors Using an Infrared Remote with Arduino
- Kotroli ya moteur ya servo ya Arduino na kosalela potentiomètre
- Kokamba ya Kopekola Esika ya Servo na Maboko na Arduino
- Controlling Two or More Servos with Potentiometers Using an Arduino
- How to Control a 360° Servo with Three Push-Button Switches
- Ndenge ya Kosalela Servo ya 360° na Arduino
- Code Arduino mpe Video ya PCA9685 16-Channel 12-Bit Servo Controller V1
- Tonga motéma ya Arduino Servo Toggle Switch na Push Button
/*
Controlling a servo position using a potentiometer (variable resistor)
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
modified on 8 November 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Knob
*/
// May 20, 2018 20:08
// Written by Ahmad S. for Robojax.com at Ajax, Ontario, Canada
// Watch the video for this code at https://youtu.be/DN1LPMSZtNA
// This code is taken from http://robojax.com/learn/arduino
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// start of servo settings *******
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = A0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int angle; // the angle servo is sent to
// END of servo settings *******
void setup() {
// Robojax Servo knob with LCD1602 Test
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
// Robojax Servo knob with LCD1602 Test
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Robojax Servo Knob");
delay(2000);
}
void loop() {
// Robojax Servo knob with LCD1602 Test
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
angle = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo.write(angle); // sets the servo position according to the scaled value
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Pot. Value:");
// set the cursor to column 0, line 1
lcd.setCursor(11, 0);
lcd.print(val);
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print("Angle :");
lcd.setCursor(11, 1);
lcd.print(angle);
delay(500);
// Robojax Servo knob with LCD1602 Test
}
Mokili na bisika
-
L'extérieurLCD1602 library (from GitHub)github.com
-
L'extérieurUsing LCD1602 LCD display for Arduinoyoutube.com
Fichiers📁
Aucun fichier disponible.