<led1.html>
<html>
<head>
<title> LED1 CGI programming!</title>
</head>
<body>
<p> LED start!</p>
<a href="cgi-bin/led1.cgi">ON</a>
</body>
</html>
wiringPi를 이용한 CGI programming
#include <stdio.h>
#include <stdlib.h>
#include <wiringPi.h>
const int Led[8] = {4, 17, 18, 27, 22, 23, 24, 25};
// 초기화시 실행 함수
void Setup(){
int i;
if(wiringPiSetupGpio()==-1)
exit(-1);
for(i=0; i<8; i++){
pinMode(Led[i], OUTPUT);
digitalWrite(Led[i], LOW);
}
}
// 버튼 동작시 수행 함수
void LedTest(){
int i;
for(i=0; i<8; i++)
digitalWrite(Led[i], HIGH);
delay(500);
for(i=0; i<8; i++)
digitalWrite(Led[i], LOW);
delay(500);
}
int main(){
// html print
printf("Content-type:text/html \n\n");
printf("<html>\n<head>\n<title>LED TEST</title>\n</head>\n");
printf("<body>\n<p>LED BLINK</p>\n");
int i;
Setup();
for(i=0; i<5; i++) // 5번 반복
LedTest();
printf("</body>\n</html>\n");
return 0;
}