程澄
New Member
ура
Posts: 29
|
Post by 程澄 on Jan 17, 2021 9:16:37 GMT
干货程。新作品,欢迎大家来交流:这是外观与接线
本作品用了面包板,UNO版,LCD1602显示屏,超声波模块。 加了blender纸模外观:(有点丑,请见谅)
产品优点:
1.实用,有显示屏提示 2.美观(其实这一条是凑数的)
代码如下(不要直接复制!!!)#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int val;
#define T 2
#define E 3
float cm;
float temp;
void setup() {
// put your setup code here, to run once:
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("length(cm):");
pinMode(12,INPUT);
Serial.begin(9600);
pinMode(T,OUTPUT);
pinMode(E,INPUT);
}
void loop() {
// put your main code here, to run repeatedly
val=digitalRead(12);
digitalWrite(T,LOW);
delayMicroseconds(2);
digitalWrite(T,HIGH);
delayMicroseconds(10);
digitalWrite(T,LOW);
temp = float(pulseIn(E, HIGH));
cm = (temp*17)/1000;
Serial.print("距离 cm =");
Serial.println(cm,3);
delay(300);
if (cm<10){
lcd.setCursor(0,1);
lcd.print("FBIwarning");
lcd.setCursor(11,0);
lcd.print(cm);
delay(300);
}
else{
lcd.setCursor(0,1);
lcd.print("safe ");//这个空格不能省
lcd.setCursor(11,0);
lcd.print(cm);
delay(500);
}
}
可能还要显示屏的库文件,在这 库文件提取码:8nb8
搬运请注明出处
求三连!!
|
|
程澄
New Member
ура
Posts: 29
|
Post by 程澄 on Jan 17, 2021 11:16:11 GMT
妙啊
|
|
|
Post by 邱老师 on Jan 17, 2021 14:13:07 GMT
用blender建个模吧,把外壳设计出来 家长会上有作品展示,准备一下!
|
|
程澄
New Member
ура
Posts: 29
|
Post by 程澄 on Jan 20, 2021 9:20:27 GMT
好的
|
|
程澄
New Member
ура
Posts: 29
|
Post by 程澄 on Jan 29, 2021 6:15:28 GMT
用blender建个模吧,把外壳设计出来 家长会上有作品展示,准备一下! 老师做好了,来康康
|
|