You are here

PSoC 5LP Reading Pins | Cypress Semiconductor

PSoC 5LP Reading Pins

Summary: 8 Replies, Latest post by Cyperion on 19 Nov 2016 08:48 AM PST
Verified Answers: 2
Last post
Log in to post new comments.
AvethoPlays_2007616's picture
User
9 posts

I am very new to PSoC, and have very limited experience with C++, and none with C. I am trying to read the signal on a pin and toggle a boolean value to change the blinking speed of an external LED. Here's the code:

int main()
{
    bool button1;
    LCD_Char_Start();
    LCD_Char_PrintString("Hola Mundo!");

    for(;;)
    {
        if(CyPins_ReadPin(Pin_1_0) !=0) {
            button1 = !button1;
            CyDelay(100);
        }
        if(button1) {
            CyDelay(1000u);
        } else {
            CyDelay(250u);
        }
        P0_0_Write(!P0_0_Read());
    }
}

The CyPins thing I got from another thread and the LCD stuff is from the Hello World example project. The LCD doesn't work though. I also kept include project.h and added stdbool.h for booleans. Any idea what I might be doing wrong?

Edit: I should probably mention I have the CY8CKIT-059 and if it matters to mention too, the chip is the CY8C5888LTI-LP097.

user_242978793's picture
User
1040 posts

Here is a PDF on how to use pins .  It is written for the PSOC 4 but applies to your device as well.  Also don't forget to check the schematic for your kit to insure that there is not a capacitor or other device on your chosen pins that may interfere with the design. 

user_242978793's picture
User
1040 posts

You can do it all in hardware with out any code.  Check out this example. I am running PSOC 4.0

AvethoPlays_2007616's picture
User
9 posts

My goal is to do it in code so I can learn C though. I want to be able to make an LCD have a menu that I can go through with buttons for a signal generator, but for now, the LED is all, the basics.

Edit: Sorry if I sounded harsh, but I was a bit peeved after trying at the LCD with example code. Thanks for the input :)

user_1377889's picture
User
9617 posts

Can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

 

Bob

AvethoPlays_2007616's picture
User
9 posts

Here you go Bob, by request, the Workspace Bundle.

AvethoPlays_2007616's picture
User
9 posts

You guys may be glad to know I got the LCD working, I had the first two pins on the port, pins 4 and 5 on the 44780 display swapped. But the problem with pin reading still stands ;(

user_1377889's picture
User
9617 posts

Yoy may use Pin_2_Read() which is independent from changing the underlying real pin. When the pin is connected to a switch that connects the pin to GND (which is the usual/preferred case) the pin should be configured as resistive pull up, initial drive high.

 

Bob

AvethoPlays_2007616's picture
User
9 posts

Thanks so much Bob! :D

I was in Toronto all yesterday so I couldn't reach the web. Now I got to decide what to make my PSoC do :)

Log in to post new comments.