Recently I tried making an XBOX controller adapter for my PC as per these instructions. As I have very little electrical knowledge, immediately I ran into problems.
Connected everything as shown and using the code provided, nothing works, it doesn't turn on.
While using my own code, it works (somewhat):
int sync_pin = 2;
int data_pin = 3;
int clock_pin = 4;
int led_cmd[10] = {0,0,1,0,0,0,0,1,0,0};
int anim_cmd[10] = {0,0,1,0,0,0,0,1,0,1};
int sync_cmd[10] = {0,0,0,0,0,0,0,1,0,0};
void setup()
{
Serial.begin(9600);
Serial.write("Initializing..");
Init();
SendData(anim_cmd, 7000);
}
void loop()
{
}
void SendData(int data[], int delay_ms)
{
pinMode(data_pin, OUTPUT);
digitalWrite(data_pin, LOW);
int prev = 1;
for (int i = 0; i < 10; i++)
{
while (prev == digitalRead(clock_pin)) { }
prev = digitalRead(clock_pin);
digitalWrite(data_pin, byte(data[i]));
while (prev == digitalRead(clock_pin)) { }
prev = digitalRead(clock_pin);
}
digitalWrite(data_pin, HIGH);
pinMode(data_pin, INPUT);
delay(delay_ms);
}
void Init()
{
pinMode(data_pin, INPUT);
pinMode(clock_pin, INPUT);
digitalWrite(clock_pin, HIGH); // SOMEHOW IT NEVER WORKS WITHOUT THIS LINE!!!
SendData(led_cmd, 0);
delay(50);
}
It turns on not every time. It syncs - at times.
The biggest problem is that whenever I touch the RF module or Arduino, or even when I wave my hand near it, the whole thing goes nuts. It starts blinking, turning on or off, and the Arduino restarts.
As I've mentioned, I'm new to electronics, so I've probably connected something wrong. All I did was directly connect the RF module to the pins on the Arduino. No resistors or diodes. Nothing. One thing I could think of was to shield the wires with some foil. :)
So if I didn't yet destroy my equipment, maybe somebody knows what could be done.