私は現在、C#を使ってラズベリーパイロボット車を作るプロジェクトに取り組んでいます。私はC#の知識は全く持っていないので、これは私の学習方法です。ラズベリーのGPIO#
車はモーターを制御するためにL298Nを使用しているので、piを1つのピンからハイに出力する方法と、低いものを出力する方法を理解する必要があります。
しかし、要点は、モーターの1つを作動させることを望むコードを書きましたが、そうではありません。私はC#とGPIOピンをよく理解している人がエラーを指摘できることを望んでいました。あなたはGPIOピン5はである見ることができるようにhttps://www.raspberrypi.org/documentation/usage/gpio-plus-and-raspi2/
:あなたはGPIOピンは、あなたがこのGPIOピンマップを使用することができます正しいものである全くわからない場合
おかげで、して、Callum
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Devices.Gpio;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace App4
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public void GPIO()
{
GpioController gpio = GpioController.GetDefault();
if (gpio == null)
return;
using (GpioPin pin1 = gpio.OpenPin(5))
{
pin1.Write(GpioPinValue.High);
pin1.SetDriveMode(GpioPinDriveMode.Output);
}
using (GpioPin pin2 = gpio.OpenPin(6))
{
pin2.Write(GpioPinValue.Low);
pin2.SetDriveMode(GpioPinDriveMode.Output);
}
}
}
}
私はC#でGPIOを知っているわけではありませんが、書き込む前に 'SetDriveMode'を出力することをお勧めします。 – MrZander