I made a custom relay board to learn PCB design and various other things. I am running into a problem where whenever I hook up my PCB, the digital pin HIGH/LOW state wont change. So to just get some general knowledge of the problem I disconnected one of my bodge wires on the PCB so the circuit was open. Whenever I opened the circuit the digital pin state changed from high to low fine. But whenever I put the wire back and closed the circuit, the digital pin state would be stuck in its original state. I'm thinking this might be something to do with a pull-up resistor not being in the design but I'm not entirely sure on if that is a relevant fix or not. I included pictures of the schematic, the serial output message when the circuit was closed (the one with the alternating 1's and 0's), and the serial output message when the circuit was open (the one with all 0's).
Code:
void setup() {
Serial.begin(9600);
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
}
void loop() {
if (Serial.available()) {
while (Serial.available() > 0) {
char SerialRead = Serial.read();
int DigitalRead = digitalRead(4);
if (SerialRead == 'o')
{
if (digitalRead(4) == LOW) {
digitalWrite(4, HIGH);
Serial.print(DigitalRead);
}
else {
digitalWrite(4, LOW);
Serial.print(DigitalRead);
}
}
}
}
}