arduino控制ps2操纵杆

编程入门 行业动态 更新时间:2024-10-21 18:32:04

arduino控制ps2<a href=https://www.elefans.com/category/jswz/34/1735574.html style=操纵杆"/>

arduino控制ps2操纵杆

一、实物连接

二、代码实现

const int xPin = A0;     //X attach to A0
const int yPin = A1;     //Y attach to A1
const int btPin = 7;     //Bt attach to digital 7void setup()
{pinMode(btPin,INPUT); //set btpin as INPUTdigitalWrite(btPin, HIGH); //and HIGHSerial.begin(9600); //initialize serial
}void loop()
{Serial.print("X: ");//print "X: "Serial.print(analogRead(xPin),DEC); //read the value of A0 and print it in decimalSerial.print("\tY: "); //print "Y: "Serial.print(analogRead(yPin),DEC); //read the value of A1 and print it in decimalSerial.print("\tZ: "); //print "Z: "Serial.println(digitalRead(btPin)); read the value of pin7 and print itdelay(100);//delay 100ms
}

更多推荐

arduino控制ps2操纵杆

本文发布于:2024-03-14 04:01:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1735575.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:操纵杆   arduino

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!