- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
when i use pos4 to driver button , thre seting is below , the button just get the the zero, not get the one ,
i check the io ,it change from3.3 to 0v, i don;t understand wath the pin_read();
as we know it should return one pin status so it must be one or zero,
otherwise waht's means of this below describe , It's very winding.to understand; what's it means???
so it's very not friendly for new developer;
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried what Bob-san wrote by using CY8CKIT-145-40XX.
The schematic
The config of SW is
main.c
=================
#include "project.h"
int main(void)
{
uint8_t pin_state ;
CyGlobalIntEnable; /* Enable global interrupts. */
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
for(;;)
{
pin_state = SW_Read() ;
LED_Write( pin_state ) ;
}
}
=================
When I don't touch the SW, LED is off, when I push the SW, LED turns on.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To avoid a floating pin declare it as "Resistive pull up", initial drive mode "high". So the pin will get shortened to ground whenthe button is pressed.
Happy coding
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
DavidW.Zhang,
You can use this community component to detect switch buttons events:
ButtonSw32: button switch debouncer component
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SW2 connects to a button, so its drive mode should not be configured to Strong mode, connect a strong 1 to external GND directly may damage the silicon because you short internal vddio and external gnd together.
Please configure the pin to resister-pull-up drive mode, you code don't need to change.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried what Bob-san wrote by using CY8CKIT-145-40XX.
The schematic
The config of SW is
main.c
=================
#include "project.h"
int main(void)
{
uint8_t pin_state ;
CyGlobalIntEnable; /* Enable global interrupts. */
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
for(;;)
{
pin_state = SW_Read() ;
LED_Write( pin_state ) ;
}
}
=================
When I don't touch the SW, LED is off, when I push the SW, LED turns on.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
TKS everyone , it's ok ,tks;