nothing is wrong with my code, it's just my motor won't turn on, while in the same exact code, i hooked the output pin to a train crossing signal and works flawlessly, is there anything i could do, and here is the code
const int SensorPin2 = 2;
const int Motor = 4;
void setup() {
pinMode(SensorPin2, INPUT);
pinMode(SignalPin, OUTPUT);
}
void loop() {
bool sensor2State = digitalRead(SensorPin2) == LOW;
digitalWrite(Motor, sensor2State ? HIGH : LOW);
}
Assuming you are using an Arduino Uno R3, an output pin can deliver 5V at up to 20mA under normal operating conditions.
How many volts and mA does your train crossing signal need?
And how many volts and mA does your motor need?
Oh, and regardless of its voltage and current requirements, if you have connected a motor directly to an output pin without a flyback diode across it, you will not have a working pin for very long.
ok, i'll just think of something else, because, i obviously don't have everything i need to make what i wanna do work, so yeah, but thank's for the help, i just might use it another day