static int Main() { Console.CancelKeyPress += Console_CancelKeyPress; // Init with BCM GPIO numbers if (WiringPi.WiringPiSetupGpio() == -1) { Console.WriteLine("wiringPiSetup failed"); return(1); } Console.WriteLine("Raspberry Pi traffic light (press ctrl+c to quit)"); WiringPi.PinMode(Red, WiringPi.Output); WiringPi.PinMode(Yellow, WiringPi.Output); WiringPi.PinMode(Green, WiringPi.Output); SetRYG(WiringPi.Low, WiringPi.Low, WiringPi.Low); while (!_end) { SetRYG(WiringPi.High, WiringPi.Low, WiringPi.Low); WaitMS(5000); SetRYG(WiringPi.High, WiringPi.High, WiringPi.Low); WaitMS(1000); SetRYG(WiringPi.Low, WiringPi.Low, WiringPi.High); WaitMS(4000); for (int blinkCount = 0; blinkCount < 3; blinkCount++) { if (_end) { break; } SetRYG(WiringPi.Low, WiringPi.Low, WiringPi.Low); WaitMS(1000); SetRYG(WiringPi.Low, WiringPi.Low, WiringPi.High); WaitMS(1000); } SetRYG(WiringPi.Low, WiringPi.High, WiringPi.Low); WaitMS(2000); } SetRYG(WiringPi.Low, WiringPi.Low, WiringPi.Low); WiringPi.PinMode(Red, WiringPi.Input); WiringPi.PinMode(Yellow, WiringPi.Input); WiringPi.PinMode(Green, WiringPi.Input); return(0); }
static int Main() { if (WiringPi.WiringPiSetupGpio() != -1) { Console.WriteLine("Raspberry Pi LED blinking example"); WiringPi.PinMode(LED, WiringPi.Output); for (int loop = 0; loop < 3; loop++) { WiringPi.DigitalWrite(LED, WiringPi.High); Console.WriteLine("on"); Thread.Sleep(500); WiringPi.DigitalWrite(LED, WiringPi.Low); Console.WriteLine("off"); Thread.Sleep(500); } return(0); } Console.WriteLine("wiringPiSetup error"); return(1); }