Difference between revisions of "GPIO Interface"
From Embedded Systems Learning Academy
(Created page with "This article shows how to use one of the pins on the SJ-One board as either an INPUT or OUTPUT pin. == Steps == Check to see if you have '''gpio.hpp''' in your project's ''...") |
(→Steps) |
||
Line 2: | Line 2: | ||
== Steps == | == Steps == | ||
− | + | The latest version of sample projects or development folder includes a GPIO C++ class. To use a pin for GPIO, see the source code example below : | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | To use a pin for GPIO, see the source code example below : | ||
<BR/> | <BR/> | ||
Latest revision as of 17:05, 6 November 2013
This article shows how to use one of the pins on the SJ-One board as either an INPUT or OUTPUT pin.
Steps
The latest version of sample projects or development folder includes a GPIO C++ class. To use a pin for GPIO, see the source code example below :
/// Include the GPIO file
#include "gpio.hpp"
int main(void)
{
/**
* Locate a pin on your board that you'd
* like to use either as INPUT or OUTPUT
* Let's use P1.19 (as labeled on the Board)
*
* You can use any other pins as defined by
* LPC1758_GPIO enumeration at gpio.hpp file.
*/
GPIO myPin(P1_19); // Control P1.19
myPin.setAsOutput(); // Use the pin as output pin
// Let's blink an LED on P1.19 :
while(1) {
myPin.setHigh(); // Pin will now be at 3.3v
delay_ms(100);
myPin.setLow(); // Pin will now be at 0.0v
delay_ms(100);
}
return 0;
}