📄 test_irsensor.c
字号:
#include <8051.h>
#include "ads7841.h"
/***************************** Main Program **********************************/
void main()
{
float x,y; // Distance and Analog voltage output
y = analog(0); // Read volt out if the sensor connect to channel 0 of ADS7841
y = 0.00122*y; // Convert BCD to DEC by multiply voltage by 5/4096
if ( (y > 0.4) && (y < 2.8) ) {
x = (y-0.19)/20.99; // Solve the linear equation
x = 1/x; // Inverse back get distance in cm.
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -