Arduino kartı aldım bilgisayara bağladığım zaman ON ışığı yeşil olarak devamlı yanıyor. Bunun yanında TX ışığı Turuncu renkte sürekli olarak yanıp sönüyor. TX yerine L ışığının yanması gerekmiyor mu.
< Bu mesaj bu kişi tarafından değiştirildi Türkayemre -- 9 Ekim 2016; 13:32:30 >
Arkadaşlar öncelikle herkese iyi günler kolay gelsin. Arduino Uno ile kendi direksiyon setimi yapmak istiyorum. Belli bir seviyeye kadar getirdim olayı ama bi yerde takıldım sizlerden yardım istiyorum. Direksiyon Gaz ve Fren tamam ama Debriyajı bir türlü ayarlayamadım kullandığım kodda nereyi değiştirmem gerekli acaba yardım edebilir misiniz.
X ve Y ekseni tamam Z ekseni ve X dönmeside tamam ama Y dönmesini debriyaj yapmayı başaramadım bir türlü.
Buda kullandığım kod.
/* Arduino USB Joystick HID demo */
/* Author: Darran Hunt Released into the public domain. Update by RICLAMER in 25/03/2014 to use Analog ports and digital ports This code is to be used with Arduino UNO (6 axis and 13 Button ) This code is compatible with Arduino Mega. */
#define NUM_BUTTONS 40 // you don't need to change this value #define NUM_AXES 8 // 6 axes to UNO, and 8 to MEGA. If you are using UNO, don't need to change this value.
void setup() { //set pin to input Button for ( int portId = 02; portId < 13; portId ++ ) { pinMode( portId, INPUT_PULLUP); } Serial.begin(115200); delay(200);
for (uint8_t ind = 0; ind < 8; ind++) { joyReport.axis[ind] = ind * 1000; } for (uint8_t ind = 0; ind < sizeof(joyReport.button); ind++) { joyReport.button[ind] = 0; } }
// Send an HID report to the USB interface void sendJoyReport(struct joyReport_t *report) { #ifndef DEBUG Serial.write((uint8_t *)report, sizeof(joyReport_t)); #else // dump human readable output for debugging for (uint8_t ind = 0; ind < NUM_AXES; ind++) { Serial.print("axis["); Serial.print(ind); Serial.print("]= "); Serial.print(report->axis[ind]); Serial.print(" "); } Serial.println(); for (uint8_t ind = 0; ind < NUM_BUTTONS / 8; ind++) { Serial.print("button["); Serial.print(ind); Serial.print("]= "); Serial.print(report->button[ind], HEX); Serial.print(" "); } Serial.println(); #endif }
// turn a button on void setButton(joyReport_t *joy, uint8_t button) { uint8_t index = button / 8; uint8_t bit = button - 8 * index;
joy->button[index] |= 1 << bit; }
// turn a button off void clearButton(joyReport_t *joy, uint8_t button) { uint8_t index = button / 8; uint8_t bit = button - 8 * index;
joy->button[index] &= ~(1 << bit); }
/* Read Digital port for Button Read Analog port for axis */ void loop() { // Create Matriz with value off switch button for (int bt = 1; bt < 13; bt ++) { btn[bt] = digitalRead(bt + 1); } // Power ON button if it is press. buton 17 at 28 for (int on = 01; on < 13; on++) { if (btn[on] == LOW) { setButton(&joyReport, on + 16); // Serial.println("botao ON"); // Serial.println(on+16); delay(1); } for (int on = 01; on < 13; on++) { if (btn[on] == HIGH) { clearButton(&joyReport, on + 16); } // Serial.println("Every buttons is off"); } }
/* Move all of the Analogic axis */ /* Arduino UNO have only 6 port. Will be necessary set to 0; the not used port */ /* In this example, i will use just 3 axis. X, Y, Z */ /* if you will use all 6 analog ports, set axis < 3, to axis < 5 */
Arduino kartı aldım bilgisayara bağladığım zaman ON ışığı yeşil olarak devamlı yanıyor. Bunun yanında TX ışığı Turuncu renkte sürekli olarak yanıp sönüyor. TX yerine L ışığının yanması gerekmiyor mu.
< Bu mesaj bu kişi tarafından değiştirildi Türkayemre -- 9 Ekim 2016; 13:32:30 >