micro servo 9g


20 ₪

الناشر: متجر القطع الالكترونية

القسم: محركات - متور

تاريخ النشر: 2021-02-03



SCHEMATICS: Wiring diagram






سنقدم مجموعة حالات تطبق على هذا النوع من المحركات ومع كل نوع شرح وكود للحالة






حال رقم 1

The servo tester moves the servo to zero degrees, waits 10 seconds, then moves to 90 degrees, waits 10 seconds, then moves to 180 degrees, and waits 10 seconds and does the same thing in reverse! It is great to use this to put the servo arm in a specific spot.



code
نسخ
اقتباس
عرض
تنزيل
	
								
#include <Servo.h> Servo servo void setup() { servo.attach(9); } void loop() { servo.write(0); delay(500); delay(10000); servo.write(90); delay(500); delay(10000); servo.write(180); delay(500); delay(10000); servo.write(90); delay(500); delay(10000); servo.write(0); delay(500); delay(10000); }





حالة رقم 2

It slowly goes from 0 to 180 degrees, waits a second, then goes quickly from 180 to 0 degrees! It’s looks cool when you put the arm side down on a table and run the code. It looks like the servos are doing push-ups!



code
نسخ
اقتباس
عرض
تنزيل
	
								
#include <Servo.h> Servo servo; void setup() { servo.attach(9); } void loop() { for(int i=0;i<180; i++){ servo.write(i); delay(15); } for(int i=180; i>0; i--){ servo.write(i); delay(7); } }





حالة رقم 3

the servo goes up in intervals of 10 degrees, waits a half second, then goes back to zero degrees it does this until it gets to 90 degrees.



code
نسخ
اقتباس
عرض
تنزيل
	
								
#include <Servo.h> Servo servo; void setup(){ servo.attach(9); } void loop(){ servo.write(10); delay(300); servo.write(0); delay(300); servo.write(20); delay(300); servo.write(0); delay(300); servo.write(30); delay(300); servo.write(0); delay(300); servo.write(40); delay(300); servo.write(0); delay(300); servo.write(50); delay(300); servo.write(0); delay(300); servo.write(60); delay(300); servo.write(0); delay(300); servo.write(70); delay(300); servo.write(0); delay(300); servo.write(80); delay(300); servo.write(0); delay(300); servo.write(90); delay(300); delay(1000); servo.write(0); delay(300); }





حالة رقم 4

it generates a random position and the servo writes that position, kind of obvious, right?



code
نسخ
اقتباس
عرض
تنزيل
	
								
#include <Servo.h> int pos=random(0,180); Servo servo; void setup(){ servo.attach(9); } void loop(){ servo.write(pos); delay(250); pos=random(0,180); delay(5000); }





سلة المشتريات افراغ السلة