TinyCLR OS BrainPad TrafficLight class file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using GHIElectronics.TinyCLR.Devices.Gpio; | |
using GHIElectronics.TinyCLR.Pins; | |
namespace GHIElectronics.TinyCLR.BrainPad | |
{ | |
public class TrafficLight | |
{ | |
private GpioPin Red, Yellow, Green; | |
public TrafficLight() | |
{ | |
Red = GpioController.GetDefault().OpenPin(G30.GpioPin.PA1); | |
Red.SetDriveMode(GpioPinDriveMode.Output); | |
Red.Write(GpioPinValue.Low); | |
Yellow = GpioController.GetDefault().OpenPin(G30.GpioPin.PC6); | |
Yellow.SetDriveMode(GpioPinDriveMode.Output); | |
Yellow.Write(GpioPinValue.Low); | |
Green = GpioController.GetDefault().OpenPin(G30.GpioPin.PB9); | |
Green.SetDriveMode(GpioPinDriveMode.Output); | |
Green.Write(GpioPinValue.Low); | |
} | |
public void TurnRedOn() => Red.Write(GpioPinValue.High); | |
public void TurnRedOff() => Red.Write(GpioPinValue.Low); | |
public void TurnYellowOn() => Yellow.Write(GpioPinValue.High); | |
public void TurnYellowOff() => Yellow.Write(GpioPinValue.Low); | |
public void TurnGreenOn() => Green.Write(GpioPinValue.High); | |
public void TurnGreenOff() => Green.Write(GpioPinValue.Low); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment