1 Reply Latest reply on May 30, 2017 9:16 AM by user_274318315

    Read user switch on the PSOC5LP prototyping stick?

    user_274318315

      Apologies, this must be a FAQ. See below.

        • 1. Re: Read user switch on the PSOC5LP prototyping stick?
          user_274318315

          Hope this is of some use to someone else.

             

          1. Add a pin and configure as a digital input with hardware connection.

             

          2. Set drive mode to be resistive pull up.

             

          3. Using the off-chip component catalog, add an SPST switch from the electro-mechanical section and a ground from the power section of the same.

             

          4. Wire the pin to one side of the switch, the ground to the other.

             

          5. Make sure that your 'pin_1' uses  P2.2 in the pins tab for the project if you are using the PSOC5LP stick.

             

          6. Generate the application and then you can test the switch is pressed by calling

             


          uint8_t sw_status = SW1_Read();

             

          That's it. You probably want to debounce but that is an exercise for the reader.