You are here

Read push button state | Cypress Semiconductor

Read push button state

Summary: 3 Replies, Latest post by danaaknight on 28 Jul 2013 06:13 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
eferre's picture
8 posts

 Hi all,

I'm very new to system-on-chip programming and I'm trying to read the state of a push button through a digital input pin. I have read the datasheet related to the pin configuration, but it doesn't seem to be enough for my problem. I also have looked for different example projects, but many don't run on my board (CY8CKIT-050 5LP), so it's pretty difficult for me to understand.

In debug mode I use the API function SW2_Read() to get the state (SW2 is the pin's name, assigned to P6[1]), but it always returns 0 either if I push the button or not. Any suggestions?



user_119377051's picture
866 posts

Hi eferre,

How was configure the SW2?

Check General Tab / Drive mode.

For digital input, as usually, drive mode is [High Impedance Digital]

that's input come from Strong drived signal (i.e external TTL output)

Other hand, If you connect SW2 to actual switch that grounded on push it.

Drive mode have to set to [Resistive Pull Up] as usually.

In this case, Active status is low, the value should be read '0'


eferre's picture
8 posts

 Resisitve Pull Up is the mode that works for my application. Thank you very much!

user_14586677's picture
7646 posts

This might help -    AN60024


Regards, Dana.

Log in to post new comments.