I have many toggle switches on my 'Flightgear' simpit. Now I wish to activate a led when the switch is actioned without using another pin and without more code.
This works in Wokwi, but in real life do I risk smoking my arduino?
No extra parts required if you do this.
Connect the LED/resistor between 5volt and pin.
Connect the switch between pin and ground.
Use pull up on the pin in setup(), like this. pinMode(buttonPin, INPUT_PULLUP);
Adapt your code, because the pin is normally HIGH, and LOW when the button is pushed.
Leo..
An additional 10k bleed resistor across the LED would be needed in your circuit (post#1)
If you follow the advice in post#3 then you only need a (1k) resistor in series with the LED.
The bleed resistor there is provided in software, with INPUT_PULLUP.
Leo..