gpt4 book ai didi

Android things 带 4 针双极升压电机

转载 作者:搜寻专家 更新时间:2023-11-01 09:29:05 24 4
gpt4 key购买 nike

使用 android things (Pico i.MX7D I/O) 如何控制 4 针双极步进电机。你能帮我解决一下引脚配置吗? This is my set up

如果有人知道升压电机请帮帮我... enter image description here enter image description here

最佳答案

这一定是代码...如果有小伙伴需要试试这个

public class mySampleStepper extends AppCompatActivity {

Button button_forward,button_backward;
private static final String[] leftMotorPins = { "GPIO_10", "GPIO_35", "GPIO_33", "GPIO_128" };
private ULN2003 mLeftStepper;
private int minSpeed=100;
StepDuration stepDuration;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_sample_stepper);
button_backward=findViewById(R.id.button_forward_ID);
button_forward=findViewById(R.id.button_backward_ID);

stepDuration = new StepDuration(0, minSpeed);

try {
mLeftStepper = new ULN2003(leftMotorPins[0], leftMotorPins[1], leftMotorPins[2], leftMotorPins[3]);
mLeftStepper.open();

} catch (Exception e) {
Log.e(MainActivity.TAG, "Error opening steppers", e);
}

button_forward.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mLeftStepper.setDirection(Direction.CLOCKWISE);
mLeftStepper.performStep(stepDuration);
}
});
button_backward.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mLeftStepper.setDirection(Direction.COUNTERCLOCKWISE);
mLeftStepper.performStep(stepDuration);
}
});


}

@Override
protected void onDestroy() {
super.onDestroy();
try {
mLeftStepper.close();
} catch (Exception e) {
Log.e(MainActivity.TAG, "Error opening steppers", e);
}
}

PIN 配置

我在 android things 和步进电机之间使用步进驱动器(L293D 驱动器)。 L293D driver

引脚连接

  • GPIO_10 连接到 c1b(在 L293D 驱动器上)
  • GPIO_35 连接到 c2a
  • GPIO_33 连接到 c1a
  • GPIO_128 连接到 c2b

  • 输出1、输出2、输出3、输出4分别到步进电机

快乐编码:)

关于Android things 带 4 针双极升压电机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48699729/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com