private static void SetPwmMode(GpioPin pin) { if (!pin.IsInSoftPwmMode) { pin.StartSoftPwm(0, 30); } }
private void ConfigureGPIOs() { foreach (var lightPin in lightPins) { lightPin.Value.PinMode = GpioPinDriveMode.Output; lightPin.Value.Write(GpioPinValue.Low); } //Read about pull-up and pull-down //http://raspi.tv/2013/rpi-gpio-basics-6-using-inputs-and-outputs-together-with-rpi-gpio-pull-ups-and-pull-downs doorbellPin.PinMode = GpioPinDriveMode.Input; doorbellPin.InputPullMode = GpioPinResistorPullMode.PullDown; doorlockPin.PinMode = GpioPinDriveMode.Input; doorbellPin.InputPullMode = GpioPinResistorPullMode.PullDown; alarmLedPin.PinMode = GpioPinDriveMode.Output; alarmLedPin.Write(GpioPinValue.Low); //https://raspberrypi.stackexchange.com/questions/53854/driving-pwm-output-frequency //https://projects.drogon.net/raspberry-pi/wiringpi/software-pwm-library/ buzzerPin.PinMode = GpioPinDriveMode.Output; buzzerPin.StartSoftPwm(0, 2); //If you know how to properly configure hardware PWM, please send a pull request! //The buzzer is already set to use GPIO1 (aka pin 12) which supports hardware PWM //buzzerPin.PwmClockDivisor = 16; // 1.2 Mhz //buzzerPin.PwmRange = 1200000 / 4000; // 4Khz //buzzerPin.PwmMode = PwmMode.MarkSign; //And now, how to start hardware PWM??? }
public FormStart() { InitializeComponent(); this.StartPosition = FormStartPosition.Manual; this.Left = Top = 0; this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; this.KeyPreview = true; _formOptions = new FormOptions(this); _formUserManagement = new FormUserManagement(this, _formOptions); // Query database and set state // Check to see if there's at least one user in the database if (User.GetAll().Count == 0) { _globalState = State.Uninitialized; } else { _globalState = State.Idle; } // Initialize Servo Code if (IS_LINUX) { Pi.Init <BootstrapWiringPi>(); servo = (GpioPin)Pi.Gpio[13]; servo.PinMode = GpioPinDriveMode.Output; servo.StartSoftPwm(0, 100); // Assume lock is open and close it lock_open = true; close_lock(); } // Update visibility of form components UpdateComponents(); foreach (Control control in Controls) { control.MouseClick += OnAnyMouseClick; } // Close keypad upon selection of most components foreach (Control control in Controls) { if (control != tbxPin && control != tbxUserPhone && control != btnClearTextBox && control != tbxUserName && control != tbxSecFactorPinOrCard) { control.MouseClick += keyboardClose_Leave; } } this.MouseClick += keyboardClose_Leave; // Initialize timer that refreshes the bluetooth device lists every 5 seconds base.InitializeBTRefreshBTDeviceListsTimer(); }
public SoftwarePwmDriver(GpioPin pin) { Pin = pin; if (Pin.Capabilities.Contains(PinCapability.PWM)) { Console.WriteLine($"GPIO Pin {Pin.BcmPinNumber} supports hardware PWM mode but runs software mode"); } Pin.PinMode = GpioPinDriveMode.Output; pin.StartSoftPwm(0, PwmRange); }
private void Initialize() { redPin.PinMode = GpioPinDriveMode.Output; greenPin.PinMode = GpioPinDriveMode.Output; bluePin.PinMode = GpioPinDriveMode.Output; redPin.StartSoftPwm(0, 225); greenPin.StartSoftPwm(0, 225); bluePin.StartSoftPwm(0, 225); }
public void Init() { _forwardPin.PinMode = GpioPinDriveMode.Output; _backwardPin.PinMode = GpioPinDriveMode.Output; // As we have a bit too much power for our motors, we set the pwm to 500 max but limit the range to 255 max _pwmPin.StartSoftPwm(0, 500); //_pwmPin.PinMode = GpioPinDriveMode.Output; //_pwmPin.PinMode = GpioPinDriveMode.PwmOutput; //_pwmPin.PwmMode = PwmMode.Balanced; SetSpeed(0); _sensorPin.PinMode = GpioPinDriveMode.Input; _sensorPin.InputPullMode = GpioPinResistorPullMode.PullUp; _sensorPin.RegisterInterruptCallback(EdgeDetection.RisingAndFallingEdges, this.SensorInterupt); }
public override int Write(GpioChannel channel, byte data) { ValidateChannel(channel); int pin = toPinId(channel.Pin); GpioPin gpioPin = toGpioPin(channel.Pin); switch (channel.Mode) { case GpioMode.Analog: gpioPin.PinMode = GpioPinDriveMode.Output; WiringPi.AnalogWrite(pin, (int)data); break; case GpioMode.Digital: gpioPin.PinMode = GpioPinDriveMode.Output; WiringPi.DigitalWrite(pin, data); break; case GpioMode.Pwm: gpioPin.PinMode = GpioPinDriveMode.PwmOutput; if (gpioPin.IsInSoftPwmMode) { gpioPin.StartSoftPwm(data, 255); } else { WiringPi.PwmWrite(pin, data); } break; default: throw new InvalidOperationException($"Invalid pin operation"); break; } return(1); }
public void PwmCreate(int range, int initialValue = 0) { pin.StartSoftPwm(initialValue, range); }
public void PwmCreate(int value, int range) { pin.StartSoftPwm(value, range); }