“激光发射”的版本间的差异

来自Labplus盛思维基百科
跳转至: 导航搜索
第50行: 第50行:
 
}
 
}
 
</pre>
 
</pre>
 +
 +
=== Python示例 ===
 +
<pre style="color:blue">
 +
//程序功能:人接近灯亮;远离灯不亮//
 +
from microbit import *
 +
 +
def digitalRead(pin):
 +
  pin.read_digital()
 +
  pin.set_pull(pin.NO_PULL)
 +
  return pin.read_digital()
 +
 +
 +
while True:
 +
  if digitalRead(pin2):
 +
    pin0.write_digital(1)
 +
  else:
 +
    pin0.write_digital(0)
 +
 +
</pre>
 +
 +
 +
=== 图形化示例 ===
 +
:::{|
 +
|-
 +
| [[文件:Servo sample.png|500px|无框]]
 +
|-
 +
|style="text-align:center"|'''舵机0-180°sweep摆动'''
 +
|}
 +
 +
 
== 版本历史记录 ==
 
== 版本历史记录 ==
  

2018年4月20日 (五) 17:15的版本

黑色传感器最终版12.20-09.png

概述

内置激光发射头,高电平开启激光器,低电平则否

技术参数

  • 工作电压: VCC 3.3V -5V
  • 发射功率:150mW
  • 激光波长:650nm(红色)
  • 出光功率:<5mW
  • 光点大小:15米处光直径:<φ15mm
  • 模块尺寸:24x46x7.5mm

引脚定义

VCC 电源
NC 空脚
DI 数字输入
GND

使用教程

Arduino示例

//程序功能:按键按下,发射激光;按键松开,激光关闭//
int buttonPin =2;     
int laserPin=3; 
int val;
void setup() {
  // put your setup code here, to run once:
   Serial.begin(9600);
   pinMode(buttonPin,INPUT);
   pinMode(laserPin,OUTPUT);
}

void loop() {
   val=digitalRead(buttonPin);                 
   Serial.print(val);
   if(val==HIGH)
   {
     digitalWrite(laserPin,HIGH);
   }
   else
   {
     digitalWrite(laserPin,LOW);
   }
}

Python示例

//程序功能:人接近灯亮;远离灯不亮//
from microbit import *

def digitalRead(pin):
  pin.read_digital()
  pin.set_pull(pin.NO_PULL)
  return pin.read_digital()


while True:
  if digitalRead(pin2):
    pin0.write_digital(1)
  else:
    pin0.write_digital(0)


图形化示例

Servo sample.png
舵机0-180°sweep摆动


版本历史记录

Version Date Note [+]新增[-]删除[^]修复
V2.0