Read user switch on the PSOC5LP prototyping stick?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JEv_295166
Level 3
Level 3
First like received

Apologies, this must be a FAQ. See below.

0 Likes
1 Reply
JEv_295166
Level 3
Level 3
First like received

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.

0 Likes