New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem trying to control LED using Xbox 360 wireless controller!!!! HELP!!! #149
Comments
You can not use pin 50-53, as they are used for SPI communication. Please use a different pin. |
but what about the codes? Is it okay or need some improvement? |
Why don't you just try it and see if it works? You can just do it as simple as this: /*
Example sketch for the Xbox Wireless Reciver library - developed by Kristian Lauszus
It supports up to four controllers wirelessly
For more information see the blog post: http://blog.tkjelectronics.dk/2012/12/xbox-360-receiver-added-to-the-usb-host-library/ or
send me an e-mail: kristianl@tkjelectronics.com
*/
#include <XBOXRECV.h>
// Satisfy the IDE, which needs to see the include statment in the ino too.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif
USB Usb;
XBOXRECV Xbox(&Usb);
#define LED LED_BUILTIN
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start"));
while (1); //halt
}
Serial.print(F("\r\nXbox Wireless Receiver Library Started"));
}
void loop() {
Usb.Task();
if (Xbox.XboxReceiverConnected) {
for (uint8_t i = 0; i < 4; i++) {
if (Xbox.Xbox360Connected[i])
digitalWrite(LED, Xbox.getButtonPress(B, i));
}
} else
digitalWrite(LED, LOW);
} PS: I saw your comment at my blog: http://blog.tkjelectronics.dk/2012/12/xbox-360-receiver-added-to-the-usb-host-library/comment-page-2/#comment-545324, please don't double post the same question. |
Yeah, sorry about that. Just want to find the answers quickly. Still searching for an answers.. |
Okay. This is not really related to the library though. I recommend asking at something like the Arduino forum for general programming questions. |
Anyway here is the code: bool ledState = false;
void loop() {
Usb.Task();
if (Xbox.XboxReceiverConnected) {
for (uint8_t i = 0; i < 4; i++) {
if (Xbox.Xbox360Connected[i]) {
if (Xbox.getButtonClick(B, i))
ledState = !ledState;
}
}
} else
ledState = false;
digitalWrite(LED, ledState);
} |
I've trying to make an LED to light up if I click button B. But it won't work. The LED kept light up. I don't know whats the problem..
Codes 1
Codes 2
These are samples of my codes. Both didn't work, both gave the same result, kept light up!!
NEED HELP!!!
The text was updated successfully, but these errors were encountered: