Hey, I am new to arduino, and I'm workin on a timing circuit for my IRP and having some issues. I understand if you can't help, as the board I am using is a digispark, rather than an arduino, but the digistump forum has this weird thing where the admin has to manually confirm each member so here I am. I have a couple of issues, the firstone being that my pin5 seems to be stuck high, even if i set it low. I assume that I overvolted/shorted something but idk.
My second problem is with my code, and thats why I'm posting in the programming section.
This is my code:
//contsant variables
const int goPin = 1;
const int haltPin = 2;
const int relayPin = 4;
//dependant variables
int goButtonState = 0;
int haltButtonState = 0;
void setup() {
// put your setup code here, to run once:
//sets the pins to the correct modes.
pinMode(goPin, INPUT) ;
pinMode(haltPin, INPUT) ;
pinMode(relayPin, OUTPUT) ;
//sets all pins LOW
digitalWrite(relayPin, LOW);
digitalWrite(goPin, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
//reads the states of both buttons
goButtonState = digitalRead(goPin);
haltButtonState = digitalRead(haltPin);
//checks if goButton has been pressed and sets relayPin HIGH if so.
if(goButtonState == HIGH) {
//sets relayPin HIGH, waits 5000ms, sets relayPin LOW
digitalWrite(relayPin, HIGH);
delay(5000);
digitalWrite(relayPin, LOW);
} else {
digitalWrite(relayPin, LOW);
}
if(haltButtonState == HIGH) {
//sets relay pin LOW to midigate damages
digitalWrite(relayPin, LOW);
delay(500);
digitalWrite(relayPin, LOW);
}
}
Idk exactly what is wrong with it, but it doesn't work. I have buttons hooked up to goPin and haltPin, and a relay hooked up to relayPin. I've been doing some poking with my multi meter, and when I press goButton, the voltage on relayPin stays Low. any help is appreciated.