摇杆
来自Labplus盛思维基百科
Labplus课程组(讨论 | 贡献)2018年4月20日 (五) 17:19的版本
概述
具有(X,Y)2轴模拟输出,可以制作遥控器用于控制运动物体的方向、速度等互动作品
技术参数
- 工作电压: VCC 3.3V -5V
- 模拟输出:0-VCC
- 模块尺寸:24x46x7.5mm
引脚定义
VCC | 电源 |
A1 | X轴模拟量 |
A0 | Y轴模拟量 |
GND | 地 |
使用教程
Arduino示例
//程序功能:根据遥感不同的值来分别控制两个LED灯的亮灭// int analogAPin =A0; int analogBPin =A1; int ledredPin =2; int ledbluePin =3; int a,b; void setup() { Serial.begin(9600); pinMode(analogAPin, INPUT); pinMode(analogBPin, INPUT); pinMode(ledredPin, OUTPUT); pinMode(ledbluePin,OUTPUT); } void loop() { a=analogRead(analogAPin); b=analogRead(analogBPin); Serial.println(a); if(a>600) { digitalWrite(ledredPin,HIGH); } else { digitalWrite(ledredPin,LOW); } if(b>600) { digitalWrite(ledbluePin,HIGH); } else { digitalWrite(ledbluePin,LOW); } }
MicroPython示例
//程序功能:用数码管交替显示摇杆X和Y的值// from microbit import * tm1650Init() while True: tm1650DisplayInt(pin0.read_analog()) sleep(1000) tm1650DisplayInt(pin0.read_analog()) sleep(1000)
图形化示例
版本历史记录
Version | Date | Note [+]新增[-]删除[^]修复 |
---|---|---|
V2.0 |