2016년 5월 18일 수요일

Raspberry Pi - GPIO output test with LED

Let's turn on LED using a Raspberry Pi GPIO port. Before the test, wiringPi must be installed. 

※ Be careful!!. If LED is connected to reverse polarity, it will be broken. Long leg is positive(+) and short leg is negative(-).

Component
  • Raspberry Pi 2 Model B
  • LED (Operating Voltage: 1.8V ~ 2.3V)
  • Resistor 250Ω





In order to test, make a simple code which is ledtest.c

#include <wiringPi.h>

#define LED1 1

int main(void)
{
  if(wiringPiSetup() == -1)
    return 1;

  pinMode(LED1, OUTPUT);
  digitalWrite(LED1, 1);

  return 0;
}

Complie and run the program.

pi@raspberrypi ~$ gcc -o ledtest ledtest.c -lwiringPi
pi@raspberrypi ~$ sudo ./ledtest


After run the program, LED will be turned on.

0 개의 댓글:

댓글 쓰기