#include <stdio.h>
#include <wiringPi.h>
void red(void);
void yellow(void);
void green(void);
int main()
{
/* set up the wiring pi library functions */
wiringPiSetup();
pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
/* pinMode 0 is the GPIO_0 (GPIO Zero) pin that is */
/* pin #7 on the header - green*/
/* set up GPIO_0 as an output port (as opposed to input port * /
/*pinMode 1 is GPIO_1 yellow and pinMode 2 is GPIO_2 red */
while(1)
{
green();
delay(300);
yellow();
delay(300);
red();
delay(300);
}
return (0);
/* Not necessay in C Code - main() returns 0 <--zero */
/*at the termination of program */
}
void green(void)
{
digitalWrite(0,HIGH);
delay(700);
digitalWrite(0,LOW);
}
void yellow(void)
{
digitalWrite(1,HIGH);
delay(700);
digitalWrite(1,LOW);
}
void red(void)
{
digitalWrite(2,HIGH);
delay(700);
digitalWrite(2,LOW);
}
No comments:
Post a Comment