模拟角度传感器Rotation Sensor V2

产品简介

模拟角度传感器V2.0是一个Arduino兼容的多圈高精度模拟角度传感器。它基于一个高精度的电位器,可旋转十圈,如果给此传感器输入5V电压供电,这样就是5000mV被分成了3600份(10圈),这样你旋转2度就可以调节3mV的电压变化,这样就可以精确地实现角度微小变化的互动效果。同时它可以很方便的通过传感器扩展版连接到您的Arduino板或者我们出品的DFRduino。

技术参数

引脚说明

400px-DRF0058_pin.png

颜色 功能描述
黑色 电源 -(GND)
红色 电源 + (VCC)
蓝色 信号线

使用教程

在这个教程中我们旋转模拟角度传感器即可在串口中输出此时的模拟角度传感器的模拟电压值。

准备

接线图

Analog sensor connection diagram

样例代码

const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to

int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 255);
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);

  // print the results to the serial monitor:
  Serial.print("sensor = ");
  Serial.print(sensorValue);
  Serial.print("\t output = ");
  Serial.println(outputValue);

  // wait 2 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(20);
}

结构图

Analog sensor connection diagram

Mind+(基于Scratch3.0)图形化编程

1、下载及安装软件。下载地址:https://www.mindplus.cc 详细教程:Mind+基础wiki教程-软件下载安装 2、切换到“上传模式”。 详细教程:Mind+基础wiki教程-上传模式编程流程 3、“扩展”中选择“主控板”中的“Arduino Uno”,“传感器”中加载“模拟多圈旋转角度传感器”。 详细教程:Mind+基础wiki教程-加载扩展库流程 4、进行编程,程序如下图: 5、菜单“连接设备”,“上传到设备” 6、程序上传完毕后,打开串口即可看到数据输出。详细教程:Mind+基础wiki教程-串口打印

结果

打开串口监视器,将波特率调整到9600,旋转传感器可以在串口上观察旋转的角度。

更多

DFshopping_car1.png Analog Rotation Sensor V2 (SKU: DFR0058) category: Product Manual category: DFR Series category: Sensors

category:source category:Diagram