12V automotive project

I made a brake light for a motorcycle. In order to detect when the brakes were being pressed I used a voltage divider. But I think If I were to do it again I would use a transistor and attach the 12v to the base with a large valued resistor and have the transistor pull the arduino pin to ground. That way if there is variation in the vehicle voltage, the pin still either sees 5v or 0v. My voltage divider would go from 3-5v depending on the motorcycles voltage. Works great but I think the transistor is a better idea. I guess the voltage divider would be good if you wanted to actually see about what the cars voltage was.