I am connecting one pin of the toggle switch to pin 9 and another to ground in Arduino leonardo, will this code work ?And I am not using any LEDs ,is that alright? I don't know much about Arduino programming and I am trying to use this switch for flight simulator.
How do I connect toggle switch to Arduino leonardo?Can I connect one pin to any of the digital pins and another to ground ? And I am not using any LEDs and resistance is that alright ? I am trying to use toggle switch for flight simulator.
I was trying to get the code and how to connect it ,so I posted in 2 different categories .I apologize for that and I didn't actually understand your explanation .sorry about that.
ballscrewbob has a "stock" explanation, but I will develop it.
"Cross posting" refers to posting more than one thread on either the same or different forum sections, regarding parts of the same project.
Answers may be provided for each of the aspects discussed, but a number of things happen. It is often necessary to ask the OP (Original Poster) for more information regarding the project though that information was given in an alternate posting. Since the question postings overlap, different people may go to some trouble - quite possibly up to half an hour or more of effort - to draft a detailed explanation of the same solution, and these unfortunate consequences overlap, excess expenditure of time simply accounting for the lack of information that was provided in the wrong place.
So such cross posting is essentially, simply being rude to those who are trying to help by wasting their time. A single discussion of a project where all the necessary background is provided - even if it requires back and forth question and answer and the introduction of further problems - is the most efficient approach because it is concise and contained.
There is a tutorial on this site for using switches and other items as inputs, written by Perry - have a look for it , it gives you the answers you’ll need and sample code