public static void Main() { _mcp = new MCP23008(39); // create an array of ports DigitalOutputPort[] ports = new DigitalOutputPort[8]; for (byte i = 0; i <= 7; i++) { ports[i] = _mcp.CreateOutputPort(i, false); } while (true) { // count from 0 to 7 (8 leds) for (int i = 0; i <= 7; i++) { // turn on the LED that matches the count for (byte j = 0; j <= 7; j++) { ports[j].State = (i == j); } Debug.Print("i: " + i.ToString()); Thread.Sleep(250); } } }
public Lcd2004(MCP23008 mcp) { DisplayConfig = new TextDisplayConfig { Height = 4, Width = 20 }; LCD_RS = mcp.CreateOutputPort(1, false); LCD_E = mcp.CreateOutputPort(2, false); LCD_D4 = mcp.CreateOutputPort(3, false); LCD_D5 = mcp.CreateOutputPort(4, false); LCD_D6 = mcp.CreateOutputPort(5, false); LCD_D7 = mcp.CreateOutputPort(6, false); var lite = mcp.CreateOutputPort(7, true); Initialize(); }
public static void Main() { // create our MCP23008 MCP23008 mcp = new MCP23008(39); // all address pins pulled high // create a digital output port from that mcp DigitalOutputPort relayPort = mcp.CreateOutputPort(1, false); // create a new relay using that digital output port Relay relay = new Relay(relayPort); // loop forever while (true) { // toggle the relay relay.Toggle(); Debug.Print("Relay on: " + relay.IsOn.ToString()); // wait for 5 seconds Thread.Sleep(5000); } }