Need some help on my IRP

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.

I have buttons hooked up to goPin and haltPin

So one end of the button goes to the pin and the other end goes to... ?

I suspect you have no pull up or pull down resistors, have a read of Buttons and other electro-mechanical inputs (introduction) - General Electronics - Arduino Forum, I think your answer will be in there.

++Karma; // For correctly posted code on your first post.

I don't think it affects my answer, but what on earth is an 'IRP'?

Sorry about the unclear wording. The other end of the buttons goes to 5V through a 330 ohm resistor.

PS.
IRP stands for independent research project. they make you do them like every year in school now.

Sorry about the unclear wording. The other end of the buttons goes to 5V through a 330 ohm resistor.

OK, well, that's why it doesn't work. Read the tutorial I suggested, it tells you what you need.

Your use of delay will also cause problems but one step at a time, the tutorial partly covers that too, although there are other tutorials that cover it better.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.