ماژول جوی استیک دو محوره Dual-axis XY Joystick
بسیاری از پروژه های روباتیک به جوی استیک نیاز دارند. این ماژول راه حل مناسبی برای کنترل ربات ها فراهم می کند، خروجی های این ماژول به دو ورودی آنالوگ متصل می شود تا روبات مطابق دستورات شما با X و Y کنترل شود، همچنین این ماژول دارای یک سویچ است که می تواند به پین دیجیتال متصل شود، ماژول جوی استیک نیز مثل سایر ماژول های موجود در فروشگاه به آسانی به آردوینو و سایر میکروها قابل اتصال است.
ویژگی ها
نوع ارتباط: آنالوگ
دارای دو محور X و Y و کلید(SW)
کد
نمونه کد کنترل دو سرو موتور با استفاده از ماژول جوی استیککد:int JoyStick_X = 0; //x int JoyStick_Y = 1; //y int JoyStick_Z = 3; //key void setup() { pinMode(JoyStick_Z, INPUT); Serial.begin(9600); // 9600 bps } void loop() { int x,y,z; x=analogRead(JoyStick_X); y=analogRead(JoyStick_Y); z=digitalRead(JoyStick_Z); Serial.print(x ,DEC); Serial.print(","); Serial.print(y ,DEC); Serial.print(","); Serial.println(z ,DEC); delay(100); }
کد:#include <Servo.h> Servo tilt, pan; // create servo object to control a servo int joyX = A0; // analog pin used to connect the X - axis of Joystick int joyY = A1; // analog pin used to connect the Y - axis of Joystick int x, y; // variables to read the values from the analog pins void setup() { tilt.attach(9); // attaches the tilt servo on pin 9 to the servo object pan.attach(10); // attaches the pan servo on pin 10 to the servo object } void loop() { x = joyX; // reads the value of the Joystick's X - axis (value between 0 and 1023) y = joyY; // reads the value of the Joystick's Y - axis (value between 0 and 1023) x = map(analogRead(joyX), 0, 1023, 900, 2100); // scale it to use with the servo b/w 900 usec to 2100 usec y = map(analogRead(joyY), 0, 1023, 900, 2100); tilt.write(x); // sets the servo position according to the scaled value pan.write(y); delay(15); // waits for the servos to get there }
جهت سفارش این کالا، به این بخش در فروشگاه آفتاب رایانه مراجعه نمایید.
مرجع:
Joystick Module For Arduino- Robot Wiki
Servo Control with Joystick and Arduino - Explore Labs


1 لایک
LinkBack URL
About LinkBacks



پاسخ با نقل قول
