I'll give you a bit of background first, I'm a bit of a general Modder with no real concrete skills in any area but like to have a play and usual do ok with a bit of google / forum finding.
A few months ago a friend asked me to take a look at some simple soldering for him to repair a xbox 360 pad for his kids birthday as he broke the rapidfire chip wiring when replacing the outer case. He would have liked a couple more pads for when his mates come over but didn't want one of the super multi mode chips which are available on eBay etc, so this got me thinking it can't be too hard to knock something basic up and throw it on a attiny85 as I've got a few spares.
So having played for a bit, I got this code below to work well via the Arduino when hooked up to a pad for testing.
//const int ledpin = 13;
const int LbuttonPin = 2;
const int Ltriggerpin = 3;
const int RbuttonPin = 4;
const int Rtriggerpin = 5;
void setup() {
// pinMode(ledpin, OUTPUT);
pinMode(LbuttonPin, INPUT);
pinMode(RbuttonPin, INPUT);
pinMode(Ltriggerpin, OUTPUT);
pinMode(Rtriggerpin, OUTPUT);
randomSeed(analogRead(4));
}
void loop(){
// LbuttonState = digitalRead(LbuttonPin);
if ((digitalRead(RbuttonPin) == HIGH) && (digitalRead(LbuttonPin) == HIGH)){
// digitalWrite(ledpin, HIGH);
analogWrite(Rtriggerpin, 100);
delay(40);
analogWrite(Ltriggerpin, 100);
delay(random(40, 60));
analogWrite(Rtriggerpin, 0);
analogWrite(Ltriggerpin, 0);
} else {
if (digitalRead(RbuttonPin) == HIGH) {
// digitalWrite(ledpin, HIGH);
analogWrite(Rtriggerpin, 100);
delay(random(50, 60));
analogWrite(Rtriggerpin, 0);
}
if (digitalRead(LbuttonPin) == HIGH) {
// digitalWrite(ledpin, HIGH);
analogWrite(Ltriggerpin, 100);
delay(random(50, 60));
analogWrite(Ltriggerpin, 0);
}
}
// digitalWrite(ledpin, LOW);
analogWrite(Ltriggerpin, 0);
analogWrite(Rtriggerpin, 0);
}
I changed the pins to those below and transferred it to the Attiny85 using the ArduinoISP (as 1MHz) and overall it worked ok.
const int LbuttonPin = 2; //2
const int Ltriggerpin = 0; //0
const int RbuttonPin = 3; //3
const int Rtriggerpin = 1; //1
Problem I'm finding is where the action of firing the gun comes in, its was timed lovely on the Arduino but on the attiny85 its very hit and miss. It will shoot 3 or 4 times very rapid then it will be like it misses a few goes then just a single shot, then a couple together.
As the code works on the Arduino I expect its my lack of attiny85 knowledge tripping me up so I've after some suggestions on how best to troubleshoot it. If you need the breadboard layout let me know and I'll try to put something together.