Hi Everyone,
I have a circuit, and it works (but if you see some issue please write to me), see attached.
The question is:
since I have a tilt component and I can put it up or down in my final version, in this situation is better to have a normal operation with the tilt open (and let the V5 connected to the PIN) or closed (and have the V5 connected to the GND through a R)?
Or said in a different way: one of the two options have a problem long term regarding heating and working?
Thanks,
Tomaso
The easy/safe way to connect a switch to the Arduino is to connect the switch between pin and ground.
And use the internal pull up on the pin, so you don't need any external resistor at all.
The pin is normally HIGH, and becomes LOW when the switch is closed.
const byte switchPin = 2;
void setup() {
pinMode(switchPin, INPUT_PULLUP); // enable internal pull up
}
void loop() {
if (digitalRead(switchPin) == LOW) // if pressed/closed
{
// do things
}
}
150k is waay to high for LEDs. You probablly won't be able to see them lit up with that value.
Maybe you meant 150 ohm.
Leo..
Not sure whether you are talking about switch or LED. You must use a series resistor to drive an LED, 150 ohms or more, or you will overload the chip and the LED and can damage both.