Content originally posted in LPCWare by Spencer on Thu Sep 29 06:04:07 MST 2011 Dear sir: In LPC1114, for example: I want to use a two pin switch change GPIO status. How to detect GPIO 0 or 1? Thanks a lot.
Content originally posted in LPCWare by ktownsend on Fri Sep 30 03:29:21 MST 2011 Quote: Spencer Dear Zero sir:
What is the following means?
#define READ_PIN (1<5)
Thanks That 1 is less than 5. :p What you probably want to know is (1<<5), which shifts a hexadecimal 0x01 five positions to the left. You can search for "bitwise operators" or "bitwise shift" on Google which will explain what this means, but you will also need to understand hexadecimal numbers for this to make much sense so you may want to do some reading on that as well. Update: Here is a tutorial I wrote a long time ago that may help: http://www.microbuilder.eu/Tutorials/Fundamentals/Bitwise.aspx
Content originally posted in LPCWare by Spencer on Fri Sep 30 02:45:18 MST 2011 Dear Zero sir: What is the following means? #define READ_PIN (1<5) Thanks
Content originally posted in LPCWare by Ex-Zero on Thu Sep 29 06:32:10 MST 2011 Set your pin to input and read data register:
//Reading bit 5 of P0
#define READ_PIN (1<<5) //shift to select bit 5
LPC_GPIO0->DIR &= ~(READ_PIN); //input
if(LPC_GPIO0->DATA & READ_PIN) //read it
{
//wow, my pin is high
}
else
{
//damned, my pin is low
}