public class Program { static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); static string[] password = { "1", "2", "3" }; static string[] entered_password = new string[3]; static int index = 0; public static void Main() { //these are my key assigment // Column pins .The keyPad exists out of 3 colums Cpu.Pin[] ColPins = { Pins.GPIO_PIN_D5,Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D7 }; //Row pins. The keypad exists out of 4 rows. Cpu.Pin[] RowPins = { Pins.GPIO_PIN_D1,Pins.GPIO_PIN_D2,Pins.GPIO_PIN_D3,Pins.GPIO_PIN_D4 }; //initializes the new keypad MatrixKeyPad kb = new MatrixKeyPad(RowPins, ColPins); // Bind both events kb.OnKeyDown += new NativeEventHandler(kb_onKeyDown); //OutPins.OnInterrupt += new NativeEventHandler(output_OnInterrupt); Thread.Sleep(Timeout.Infinite); } //Triggered when a key is pressed //The key code //Date and time of the event static void kb_onKeyDown(uint keyCode, uint Unsed, DateTime Time) { // initializing a vailable; string key = keyCode.ToString(); int j = 0; //check at increment 2 if (index <=2) { // assign ke+y into an array Debug.Print(key+ " : " + index); entered_password[index] = key; index++; if (index >2) { if ( entered_password[0] == password[0] && entered_password[1] == password[1] && entered_password[2] == password[2]) { while (j != 3) { led.Write(true); Thread.Sleep(500); led.Write(false); Thread.Sleep(500); j++; } } } } } }
sorry for taking long to respond but that worked for me, right now i have been trying to connect the infrared sensors but i can detect transmission from a tv remote, and the led transmitter seems not to work, i want to pick data if the connection of the infra red sensors to be used, it seems not working, i connected my output to the led just in case there's something detected.