i'm trying to make an arduino controlled coil rifle. the biggest problem i'm having right now is that it currently won't fire the first stage because the projectile is already moving too fast from the injector. i have a phototransistor / ir LED setup which is supposed to fire an SCR when its interrupted.
int trigger = 2; // Trigger, will fire injector when safety is off
int triggerpin = 0; // value where trigger value is stored
int index1 = 0; // LDR value, stage 1
int index2 = 0; // LDR value, stage 2
int inputPin1 = 0; // LDR in, stage 1
int inputPin2 = 1; // LDR in, stage 2
int scrj = 4; // SCR in the first main stage
int scr1 = 3; // SCR in the injector
int scr2 = 5; // SCR in stage 2
void setup()
{
pinMode (scr1, OUTPUT);
pinMode (scrj, OUTPUT);
pinMode (scr2, OUTPUT);
pinMode (trigger, INPUT);
Serial.begin(9600); // initialize serial communication with computer
backlightOn();
}
void loop()
{
//looplcd();
index1 = analogRead (inputPin1); // sets index to LDR value
index2 = analogRead (inputPin2); // sets index2 to LDR2 value
triggerpin = digitalRead(trigger); // read input value
//Serial.println(index1 , index2); // prints LDR value, comment for final
// delay(10);
{
if (index1 < 550){
digitalWrite (scr1, HIGH);
delay(10);
}
else{
digitalWrite (scr1, LOW);
}
}
{
if (triggerpin == HIGH){
digitalWrite(scrj, HIGH); // turn SCRj ON
delay(10);
}
else{
digitalWrite(scrj, LOW); // turn SCRj OFF
}
}
}
void looplcd()
{
selectLineOne();
delay(100);
Serial.print("BAT:");
Serial.print(index1);
Serial.print("% V:99m/s");
selectLineTwo();
delay(100);
Serial.print("CAP:100% MAG:3 S");
delay(100);
}
void selectLineOne(){ //puts the cursor at line 0 char 0.
Serial.print(0xFE, BYTE); //command flag
Serial.print(128, BYTE); //position
}
void selectLineTwo(){ //puts the cursor at line 0 char 0.
Serial.print(0xFE, BYTE); //command flag
Serial.print(192, BYTE); //position
}
void goTo(int position) { //position = line 1: 0-15, line 2: 16-31, 31+ defaults back to 0
if (position<16){
Serial.print(0xFE, BYTE); //command flag
Serial.print((position+128), BYTE); //position
}
else if (position<32){
Serial.print(0xFE, BYTE); //command flag
Serial.print((position+48+128), BYTE); //position
}
else {
goTo(0);
}
}
void clearLCD(){
Serial.print(0xFE, BYTE); //command flag
Serial.print(0x01, BYTE); //clear command.
}
void backlightOn(){ //turns on the backlight
Serial.print(0x7C, BYTE); //command flag for backlight stuff
Serial.print(157, BYTE); //light level.
}
void backlightOff(){ //turns off the backlight
Serial.print(0x7C, BYTE); //command flag for backlight stuff
Serial.print(128, BYTE); //light level for off.
}
void serCommand(){ //a general function to call the command flag for issuing all other commands
Serial.print(0xFE, BYTE);
}
is there any hope for this, or am i going to have to skip the arduino and just fire it straight from the phototransistor?
also, http://coilturret.blogspot.com/ (i really need to update this x])