首页 百科知识 非接触式红外触觉探测软件的编写

非接触式红外触觉探测软件的编写

时间:2022-10-04 百科知识 版权反馈
【摘要】:非接触式红外触觉传感器一般是用来检测人体热释电的,如果检测到热释电,该模块就会在控制端口输出低电平,否则为高电平。# This is the address we setup in the Arduino Program

非接触式红外触觉传感器一般是用来检测人体热释电的,如果检测到热释电,该模块就会在控制端口输出低电平,否则为高电平。

程序如下,其在嵌入式控制器上显示热释电的情况。

底层控制板(Arduino)的范例程序如下:

#include 〈Wire.h〉

#define SLAVE_ADDRESS 0x04

int number = 0;

int state = 0;

byte sensor Pin = 16;//PC2

void setup() {

Serial.begin(9600); // start serial for output

pin Mode(sensor Pin,INPUT);

// initialize i2c as slave

Wire.begin(SLAVE_ADDRESS);

// define callbacks for i2c communication

Wire.on Receive(receive Data);

Wire.on Request(send Data);

Serial.println("Ready!");

}

void loop() {

byte state = digital Read(sensor Pin);

delay(500);

}

// callback for received data

void receive Data(int byte Count){

}

// callback for sending data

void send Data(){

int i;

Wire.write(state);

}

嵌入式控制板的范例程序如下:

import smbus

import time

# for RPI version 1, use "bus = smbus.SMBus(0)"

bus = smbus.SMBus(1)

# This is the address we setup in the Arduino Program

address = 0x04

def write Number(value):

bus.write_byte(address, value)

# bus.write_byte_data(address, 0, value)

return -1

def read Number():

number = bus.read_byte(address)

# number = bus.read_byte_data(address, 1)

return number

while True:

number = read Number()

print "PIR:" number

print

免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

我要反馈