Exemple #1
0
        public MedIOEx()
        {
            // Will extract (from embedded resource) and compile the library
            // if it doesn't exist in the same directory as LibBcm2835.dll.
            Bcm2835.ExtractAndCompileLibraryIfNotExists();

            _bcm2835 = Bcm2835.Instance;
        }
Exemple #2
0
        static int Main(string[] args)
        {
            // Will extract (from embedded resource) and compile the library
            // if it doesn't exist in the same directory as LibBcm2835.dll.
            Bcm2835.ExtractAndCompileLibraryIfNotExists();

            // Grabbing the instance will dynamically load the libbcm2835.so
            // library, so make sure it's there before accessing this property.
            Bcm2835 bcm2835 = Bcm2835.Instance;

            // If you call this, it will not actually access the GPIO
            // Use for testing
            // bcm2835.bcm2835_set_debug(1);

            if (bcm2835.bcm2835_init() == 0)
            {
                return(1);
            }

            // Set the pin to be an output
            bcm2835.bcm2835_gpio_fsel(pin, Bcm2835.HIGH);

            while (true)
            {
                // Turn it on
                bcm2835.bcm2835_gpio_write(pin, Bcm2835.HIGH);

                // wait a bit
                bcm2835.bcm2835_delay(500);

                // turn it off
                bcm2835.bcm2835_gpio_write(pin, Bcm2835.LOW);

                // wait a bit
                bcm2835.bcm2835_delay(500);
            }
            bcm2835.bcm2835_close();
            return(0);
        }