اطلاعیه

Collapse
No announcement yet.

راه اندازی Arduino for zigbee

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    راه اندازی Arduino for zigbee

    سلا م دوستان
    من میخوام که ماژول زیگبی رو به آردینو متصل کنم و بتونم چند رله رو در طرف دیگه کنترل کنم.
    البته سمت اپراتور از PS2 یا دسته پلی استیشن استفاده کردم که قبلا با NRF این کار رو انجام دادم.
    ماژول های من سری Pro S3B است که در نرم افزار XCTU تنوستم باهاش ارتباط برقرار کنم .که یعنی ماژول های من سالمه
    آموزش فارسی پیدا نکردم که با استفاده ار اون حداقل ارتباط رو برقرار کنم.و انگلیسی هم چیزی نغهمیدم.
    دوستان لطف کنید به کد های من نگاه کنید و منو راهنمایی کنید.
    سمت گیرنده :



    byte joyStick[19];
    //output
    byte Min_Pin = 9;
    byte A = 9; //:)
    byte B = 10; //:)
    byte C = 11; //:)
    byte D = 12; //:)
    int Max_Pin = 12;
    void setup() //
    {
    Serial.begin(9600);
    for (int i = Min_Pin; i <= Max_Pin; i++) {
    pinMode(i, OUTPUT);
    digitalWrite(i, HIGH);
    };
    }
    void loop()
    {
    while (Serial.available() > 0)
    {
    joyStick[8] = Serial.read();
    // *******************************
    if (joyStick[8] == 1) { // Start
    digitalWrite(A, LOW);
    } else {
    digitalWrite(A, HIGH);
    }
    // *******************************
    if (joyStick[4] == 1) { // Start
    digitalWrite(B, LOW);
    } else {
    digitalWrite(B, HIGH);
    }
    // *******************************
    if (joyStick[9] == 1) { // select
    digitalWrite(C, LOW);
    } else {
    digitalWrite(C, HIGH);
    }
    // *******************************
    if (joyStick[10] == 1) {
    digitalWrite(D, LOW); // L1
    }
    if (joyStick[11] == 1) {
    digitalWrite(D, HIGH); // L2
    }
    }
    }






    سمت فرستنده:




    #include <PS2X_lib.h>
    PS2X ps2x; // create PS2 Controller Class
    int error = 0;
    byte type = 0;
    byte vibrate = 0;
    byte joyStick[19];
    void setup()
    {
    // 13: clock (blue) // 12: data (ghahvehei) // 11: command (naranji) // 10: attention (yellow)
    error = ps2x.config_gamepad(13, 11, 10, 12, true, true); //setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error
    Serial.begin(9600);
    }
    void loop() {
    //DualShock Controller
    ps2x.read_gamepad(false, vibrate); //read controller and set large motor to spin at 'vibrate' speed
    vibrate = ps2x.Analog(PSAB_BLUE); //this will set the large motor vibrate speed based on
    //how hard you press the blue (X) button
    // Stick Values:
    // Stick Values:
    joyStick[0] = ps2x.Analog(PSS_LY);
    joyStick[1] = ps2x.Analog(PSS_LX);
    joyStick[2] = ps2x.Analog(PSS_RY);
    joyStick[3] = ps2x.Analog(PSS_RX);


    // 4 jahat
    joyStick[4] = ps2x.Button(PSB_PAD_UP);
    joyStick[5] = ps2x.Button(PSB_PAD_DOWN);
    joyStick[6] = ps2x.Button(PSB_PAD_RIGHT);
    joyStick[7] = ps2x.Button(PSB_PAD_LEFT);


    // Start & Select
    joyStick[8] = ps2x.Button(PSB_START); vibrate = joyStick[8];
    joyStick[9] = ps2x.Button(PSB_SELECT);


    // L&R
    joyStick[10] = ps2x.Button(PSB_L1);
    joyStick[11] = ps2x.Button(PSB_R1);
    joyStick[12] = ps2x.Button(PSB_L2);
    joyStick[13] = ps2x.Button(PSB_R2);
    joyStick[14] = ps2x.Button(PSB_L3);
    joyStick[15] = ps2x.Button(PSB_R3);


    // X, Triangle, Circle, Square
    joyStick[16] = ps2x.Analog(PSAB_BLUE); // X
    joyStick[17] = ps2x.Analog(PSAB_GREEN); // Triangle (Mosallas)
    joyStick[18] = ps2x.Analog(PSAB_RED); // Circle (Dayereh)
    joyStick[19] = ps2x.Analog(PSAB_PINK); // Square (Morabba)


    Serial.print( joyStick[0] );
    Serial.print( joyStick[1] );
    Serial.print( joyStick[2] );
    Serial.print( joyStick[3] );
    Serial.print( joyStick[4] );
    Serial.print( joyStick[5] );
    Serial.print( joyStick[6] );
    Serial.print( joyStick[7] );
    Serial.print( joyStick[8] );
    Serial.print( joyStick[9] );
    Serial.print( joyStick[10] );
    Serial.print( joyStick[11] );
    Serial.print( joyStick[12] );
    Serial.print( joyStick[13] );
    Serial.print( joyStick[14] );
    Serial.print( joyStick[15] );
    Serial.print( joyStick[16] );
    Serial.print( joyStick[17] );
    Serial.print( joyStick[18] );
    Serial.print( joyStick[19] );
    }


    جدیدترین ویرایش توسط matrex; ۰۲:۴۸ ۱۳۹۶/۰۱/۱۳.
    http://upload7.ir/images/42355212667119477675.gif
    daydigi.com

    #2
    پاسخ : راه اندازی Arduino for zigbee

    من همین مشکل رو با avr دارم اونجوری که من فهمیدم اطلاعات کمی در باره ی این ماژول هست راه ارتباط بین دو ماژول zigbee هم همون نرم افزار شرکته خلاصه گشتم نبود...

    دیدگاه

    لطفا صبر کنید...
    X