예제 #1
0
        private static void ReadInputPort(Pca95x4 pca95x4)
        {
            pca95x4.Write(Register.Configuration, 0xFF);  // Make all inputs.
            byte data = pca95x4.Read(Register.InputPort);

            Console.WriteLine($"Input Port: 0x{data:X2}");
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Pca95x4 Sample!");

            using (Pca95x4 pca95x4 = GetPca95x4Device())
            {
                //CycleOutputBits(pca95x4);
                //ReadInputPort(pca95x4);
                CheckInputRegisterPolarityInversion(pca95x4);
            }
        }
예제 #3
0
        private static void CycleOutputBits(Pca95x4 pca95x4)
        {
            pca95x4.Write(Register.Configuration, 0x00); // Make all outputs.
            pca95x4.Write(Register.OutputPort, 0xFF);    // Set all outputs.

            for (int bitNumber = 0; bitNumber < 8; bitNumber++)
            {
                pca95x4.WriteBit(Register.OutputPort, bitNumber, false); // Clear output.
                Thread.Sleep(500);
                pca95x4.WriteBit(Register.OutputPort, bitNumber, true);  // Set output.
            }
        }
예제 #4
0
        private static void CheckInputRegisterPolarityInversion(Pca95x4 pca95x4)
        {
            pca95x4.Write(Register.Configuration, 0xFF);  // Make all inputs.
            byte data = pca95x4.Read(Register.InputPort);

            Console.WriteLine($"Input Register: 0x{data:X2}");
            pca95x4.InvertInputRegisterPolarity(true);
            data = pca95x4.Read(Register.InputPort);
            Console.WriteLine($"Input Register Polarity Inverted: 0x{data:X2}");
            pca95x4.InvertInputRegisterPolarity(false);
            data = pca95x4.Read(Register.InputPort);
            Console.WriteLine($"Input Register: 0x{data:X2}");
        }