بسم الله الرحمن الرحيم
Joystick Shield Example with LabVIEW
سوف نقوم فى هذا الدرس إن شاء الله بأرسال بيانات من الأردوينو (Arduino) للكمبيوتر عن طريق كابل ال USB ( Serial Communication). سوف نقوم بأستقبال البيانات على برنامج اللابفيو (سوف اقوم بعمل شرح له إن شاء الله و لكن عذراً لضيق الوقت الأن).
الأدوات المطلوبه
- أردينو اونو (Arduino Uno)
- كابل USB
- لاب توب او كمبيوتر مثبت عليه برنامج اللابفيو 2011
- Joystick Shield يمكن شرأها من موقع شركة (https://www.sparkfun.com/products/9760 )sparkfun
ملاحظه يمكن استخدام اى نوع من المقاومات المتغيره لتكون هى المدخل (Input) للاردوينو مكان الموجوده فى ال joystick
كود الأردوينو
بالرجوع للرابط الخاص بالjoystick shield نجد ان بها مدخلات كالتالى:
- خمسه digital inputعن طريق اربع push buttons ظاهره امامنا و الخامس تحت ال Thumb Joystick
- اتثنين من ال analog input لكن من محور x & y و هى الموجوده فى thumb joystick
يجب تحميل الكود التالى على الأردوينو قبل البدء
Joystick Shield Sample Sketch
Reads the buttons and joystick position of SparkFun’s Arduino Joystick Shield. The Joystick Shield is available from SparkFun’s website:
http://www.sparkfun.com/commerce/product_info.php?products_id=9490
Created Nov. 23, 2009
By Ryan Owens
*/
//Create variables for each button on the Joystick Shield to assign the pin numbers
char button0=3, button1=4, button2=5, button3=6;
char sel=2;
void setup(void)
{
pinMode(sel, INPUT); //Set the Joystick ‘Select’button as an input
digitalWrite(sel, HIGH); //Enable the pull-up resistor on the select button
pinMode(button0, INPUT); //Set the Joystick button 0 as an input
digitalWrite(button0, HIGH); //Enable the pull-up resistor on button 0
pinMode(button1, INPUT); //Set the Joystick button 1 as an input
digitalWrite(button1, HIGH); //Enable the pull-up resistor on button 1
pinMode(button2, INPUT); //Set the Joystick button 2 as an input
digitalWrite(button2, HIGH); //Enable the pull-up resistor on button 2
pinMode(button3, INPUT); //Set the Joystick button 3 as an input
digitalWrite(button3, HIGH); //Enable the pull-up resistor on button 3
Serial.begin(9600); //Turn on the Serial Port at 9600 bps
}
void loop(void)
{
Serial.print(analogRead(0)); //Read the position of the joysticks X axis and print it on the serial port.
Serial.print(“,”);
Serial.print(analogRead(1)); //Read the position of the joysticks Y axis and print it on the serial port.
Serial.print(“,”);
Serial.print(digitalRead(sel)); //Read the value of the select button and print it on the serial port.
Serial.print(digitalRead(button0)); //Read the value of the button 0 and print it on the serial port.
Serial.print(digitalRead(button1)); //Read the value of the button 1 and print it on the serial port.
Serial.print(digitalRead(button2)); //Read the value of the button 2 and print it on the serial port.
Serial.println(digitalRead(button3)); //Read the value of the button 3 and print it on the serial port.
//Wait for 1000 ms, then go back to the beginning of ‘loop’ and repeat.
delay(1000);
}
يرسل الأردينو من خلال السيريال بورت قيم الأربع pushbuttons مع قيم الأتجاهات (X & Y )الى الكمبيوتر حيث تكون البيانات كالتالى
يمكن استقبال البيانات السابقه على برنامج hyperterminal او من خلال برنامج الاردوينو نفسه عن طريق الضغط على Ctrl+Shift+M
فى هذا التطبيق سوف اقوم بأستقبال البيانات على برنامج اللابفيو لعرضها بصوره افضل و معبره. مثال بدلاً من عرض الرقم”1” و الذى يعبر ان احد الأزره (Pushbutton) مضغطوط سوف نعبر عنها بشكل زر او ليد LEDتضيئ عند الضغط على الزر فى ال joystick Shield.
يمكنك تحميل VI لبرنامج اللابفيو التى تعمل مع هذا الدرس من الرابط التالىConnect Joystick Shield to Arduino and LabvIEW
قد يبدو بعض الشرح غريبا إن كنت من المبتدئين. أرجو المعذره حتى يتسنى ليا الوقت لأقوم بشرح برنامج اللأب فيو بأستفاضه.
يمكنك تحميل VI لبرنامج اللابفيو التى تعمل مع هذا الدرس من الرابط التالىConnect Joystick Shield to Arduino and LabvIEW
at | Permalink
جميل
at | Permalink
جميل
at | Permalink
جميل
at | Permalink
جميل