赞
踩
- #include <Arduino.h>
-
- const int x = 32;
- const int y = 33;
- const int key = 35;
-
- void setup(){
- Serial.begin(115200);
- pinMode(key,INPUT);
- }
- //接线 电源5V SW 接35脚 数字量输入 VRX接32脚 VRY接33脚 模拟量输入
- //x_value y_value 模拟量值得变化范围 0 - 4095 默认摇杆中间位置在2800左右
- //x轴 左侧到右侧变化范围 0-4095 y轴 上面到下面变化范围 0-4095
- //key_value 默认值为1 按下值为0
- void loop(){
- int x_value = analogRead(x);
- int y_value = analogRead(y);
- int key_value = digitalRead(key);
- Serial.print(x_value);
- Serial.print(",");
- Serial.print(y_value);
- Serial.print(",");
- Serial.println(key_value);
- delay(100);
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。