Ce tutoriel fait partie de: servomoteurs
Vous trouverez ici une liste de toutes les vidéos relatives aux servomoteurs. D'autres liens vers ces vidéos sont disponibles plus bas.
How to Control a 360° Servo with Three Push-Button Switches
This code controls the 360 servo with three push buttons (CW, CCW, and STOP). Watch the video for details.
Ce tutoriel fait partie de: servomoteurs
- Contrôler un servomoteur avec des boutons-poussoirs à l'aide d'un 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)
- Contrôler un servomoteur avec un potentiomètre à l'aide d'un Arduino
- Contrôler un servomoteur avec un potentiomètre et un écran LCD1602 à l'aide d'un Arduino
- Contrôler des servomoteurs à l'aide d'une télécommande infrarouge avec Arduino
- Contrôle de moteur servo Arduino à l'aide d'un potentiomètre
- Contrôle de la position du servo avec des gestes de la main pour Arduino
- Controlling Two or More Servos with Potentiometers Using an Arduino
- How to Use Continuous 360° Servo with Arduino
- Code Arduino et vidéo pour le contrôleur de servomoteurs PCA9685 16 canaux 12 bits V1
- Build an Arduino Servo Toggle Switch with a Push Button
209-How to control a 360 servo with push buttons
Langue: C++
++
/*
* S05-13 Servo with 3 push buttons
* Demonstration of Controlling a Continuous Servo (360 servo)
* This code allows you to control a 360-degree servo using push buttons
*
* Modified by Ahmad Shamshiri for Robojax Robojax.com
* on Jan 17, 2019 at 22:42 in Ajax, Ontario, Canada
Watch the video instruction for this sketch: https://youtu.be/hVe4TSRV4ww
Watch Introduction to 360 Servo video with code: https://youtu.be/b_xvu6wWafA
You can get the wiring diagram from my Arduino Course at Udemy.com
Learn Arduino step by step with all libraries, codes, and wiring diagrams all in one place
visit my course now http://robojax.com/L/?id=62
If you found this tutorial helpful, please support me so I can continue creating
content like this.
or make a donation using PayPal http://robojax.com/L/?id=64
Original code by BARRAGAN <http://barraganstudio.com>
*
* Code is available at http://robojax.com/learn/arduino
* This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.
* This code has been downloaded from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int servoPin = 9;// this pin must be one of those with PWM ~
#define STOPpin 3 // push button pin for STOP
#define CWpin 2 // push button for CW
#define CCWpin 4 // push button for CCW
int sc[]={106, 58, 0};// servo commands are in order
//CCW, STOP,CW
String scText[]={"CCW","Stop","CW"};// define texts for 3 actions
int statusText;
int CWBS, CCWBS, SBS;
//CW button status (CWBS)
//CCW button status (CCWBS)
//stop button status (SBS)
void setup() {
Serial.begin(9600);
pinMode(STOPpin,INPUT_PULLUP);// set pin for push button STOP
pinMode(CCWpin,INPUT_PULLUP);// set pin for push button CCW
pinMode(CWpin,INPUT_PULLUP);// set pin for push button CW
myservo.attach(servoPin); // attaches the servo on pin 9 to the servo object
myservo.write(sc[1]);// send STOP command
statusText=1;// initial value is STOP
}
void loop() {
CCWBS = digitalRead(CCWpin);// read status of button CCW
SBS = digitalRead(STOPpin);// read status of button STOP
CWBS = digitalRead(CWpin);// read status of button CW
if(CCWBS ==LOW)
{
servoCommand(0);
}else if(SBS ==LOW)
{
servoCommand(1);
}else if(CWBS ==LOW)
{
servoCommand(2);
}
Serial.println(scText[statusText]);
delay(50);
}// loop
void servoCommand(int n)
{
statusText = n;
myservo.write(sc[n]);
Serial.print("Going to ");
Serial.print(scText[n]);
Serial.print( "(");
Serial.print(sc[n]);
Serial.println(")");
}
Ressources et références
Aucune ressource pour le moment.
Fichiers📁
Aucun fichier disponible.