10. 火焰传感器

10.1. 概述

火焰传感器,可以实现对火焰的检测,适合所有火焰探测需要的场合,例如灭火机器人、火焰报警器。尽管火焰传感器是用来感知火焰,但是它并不防火。因此使用时请与火焰保持一定距离,以免烧坏传感器。火焰越大,数值越小。

../../_images/20-1.png
  • 技术规格
    • 工作电源:3.3V
    • 尺寸:3.14 x 18 ²mm
    • 接口类型 :3PIN直插接口
    • 设备类型:模拟输入
  • 接口定义
    • V:电源正极
    • G:电源负极
    • S:信号线

10.2. 案例程序

图形化:
../../_images/20-2.png
代码:
from mpython import *

p1 = MPythonPin(1, PinMode.ANALOG)

import time
while True:
    oled.fill(0)
    oled.DispChar((str(p1.read_analog())), 0, 0, 1)
    oled.show()
    time.sleep(1)
    if p1.read_analog() < 600:
        rgb.fill((int(255), int(0), int(0)))
        rgb.write()
        time.sleep_ms(1)
    else:
        rgb.fill( (0, 0, 0) )
        rgb.write()
        time.sleep_ms(1)