Getting them setup was a pain on my windows machine, but eventually I got them to program ok. The problem is that they don't fire off the laser. I finally put my whole project on a breadboard and if I plug the same 4 wires (5v, gnd, 3, 5) between the mega and this new one, it works on the mega but not the new one. Is there something I could be missing in either wiring or coding that would cause this? Am I thinking about the tiny85 wrong in some way?
Here's my code...
/*
The circuit:
* LASER attached to pin 6
* pushbutton attached to pin 3 from +5V
* 10K resistor attached to pin 3 from ground3
*/
const int trigger = 3;
//const int safety = 5; //temporarily eliminated safety with tigger
const int ledPin = 5; // goes to LASER
const int burstSize = 3; // How many shots in a burst
void setup() {
Serial.begin(9600);
pinMode(ledPin , OUTPUT);
pinMode(trigger , INPUT);
//pinMode(safety , INPUT);
}
int releaseState = 1;
void loop() {
// read the state of the pushbutton value:
int triggerState = digitalRead(trigger);
//int safetyState = digitalRead(safety);
if(releaseState == 1){
if (triggerState == HIGH) {
releaseState = 0;
Serial.println("fire");
digitalWrite(ledPin, HIGH);
delay(250);
digitalWrite(ledPin, LOW);
}
}
//force the person to release the trigger
if (triggerState == LOW) {
releaseState = 1;
}
}
Are you keeping the difference between physical pins and arduino pins straight? Arduino functions need the arduino pin number - to see the mapping of arduino pins to physical pins, consult the pinout diagram. The specific mapping of the arduino pin numbers to physical pin numbers is determined by the third party hardware package you're using to support the tiny85, but the one linked below is pretty ubiquitous. My guess is you're confused here, since pin5 (arduino pin numbers) is almost always the reset pin, which isn't even available for use normally!
If you're actually using some VUSB board (you should mention this if so - they're really quite a different animal from a standard tiny85), many of them do have RSTDSBL set to make that pin usable (reprogramming is achieved through VUSB bootloader) - but the reset pin still doesn't have much drive strength (I think this is a technical compromise to make HVSP possible), so you should not use it as an output.
Hi DrAzzy,
I appreciate your reply. I guess the correct answer is that I don't know what exactly I have. The one on the ebay link is the actual one I bought.
The pins are labeled on the tiny board as P0-P5 on the front of the board on the other side of the board, it's labeled as
It took me a few times reading your post and a little google-fu, but I realized that I needed to connect the trigger to pin 0 and the laser to pin 1. THANK you for both your time and for your thoughtful, non-judgmental response. It is much appreciated.
That's a VUSB bootloader one. It may or may not have pin5 set to work as an IO pin - but as I said, even if it is, it can't output much current at all. .
You're making a lasergame, that's really interesting man! May I ask what kind of sensors you're using for the laser? Or do you just use a beam with a wide range?