Exemple #1
0
        public static void Main()
        {
            SoftPwm _pwm = new SoftPwm(N.Pins.GPIO_PIN_D12);

            while (true)
            {
                // start our PWM with defaults (50% duty cycle, 1hz) and run for
                // 5 seconds
                Debug.Print("Start @ 1hz, 50% dutycycle.");
                _pwm.Start();
                Thread.Sleep(5000);

                // manually stop/start at 4hz fequency and a 25% dutycycle
                Debug.Print("4hz, 25% dutycycle");
                _pwm.Stop();
                _pwm.Frequency = 4;
                _pwm.DutyCycle = 0.25f;
                _pwm.Start();
                Thread.Sleep(5000);

                // change it up again, while it's still running
                Debug.Print("8hz, 50% dutycycle");
                _pwm.Frequency = 8;
                _pwm.DutyCycle = 0.5f;
                Thread.Sleep(5000);

                // stop and reset to defaults
                _pwm.Stop();
                _pwm.Frequency = 1.0f;
                _pwm.DutyCycle = 0.5f;
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            //int ret = Init.WiringPiSetup();
            int ret = Init.WiringPiSetupGpio();

            if (ret == -1)
            {
                Console.WriteLine("Init failed: {0}", ret);
                return;
            }
            int range = -1;
            int value = -1;
            int pin   = 0;

            try {
                pin   = Int32.Parse(args[0]);
                range = Int32.Parse(args[1]);
                value = Int32.Parse(args[2]);
            } catch {
                Console.WriteLine("Parse Error");
                return;
            }
            Console.WriteLine("range:{0}, value:{1}", range, value);
            SoftPwm.Create(pin, value, range);
            Console.WriteLine("Init succeeded");

            SoftPwm.Write(pin, value);
            Console.ReadKey(true);
            SoftPwm.Stop(pin);
            Thread.Sleep(100);
        }