Download library here.

 
GPIO WRITE
 

 

#include "lpc17xx.h"
#include "GPIO.h"
#include "timer.h"

int main(void)
{
	GPIOSetDir(LED9, OUTPUT);       //Set LED 9 as output

	TimerInit(0, 1000);             //Initialize timer 0

	while(1)
    {
        GPIOSetValue(LED9, HIGH);   //Set LED 9 
        delayMs(0,500);             //Delay 0.5s
        GPIOSetValue(LED9, LOW);    //Reset LED 9
        delayMs(0,500);             //Delay 0.5s
    }
}


GPIO READ

#include "lpc17xx.h"
#include "lpc_types.h"
#include "gpio.h"
#include "timer.h"

int main (void)
{
	GPIOSetDir(1, 25, OUTPUT);			//Declare led 1.27
	GPIOSetDir(1, 27, INPUT);			//Declare button 1.17
	GPIOSetPull(1, 27, PULLUP);			//Pull-up resistor for button 1.17
	uint32_t var;						//Declare variable

	while(1)
	{
		var = GPIOGetValue(1, 27);		//Read the button value

		if (var == 0)					//If the button is pushed
		{
			GPIOSetValue(1, 25, HIGH); 	//Led high
		}
		else							//The button is not pushed
		{
			GPIOSetValue(1, 25, LOW); 	//Led low
		}
	}
}

 

Copyright 2011. Joomla 1.7 templates - Joomla template maker. The Simplecortex is developed by BRC-Electronics