[2020]'春节宅家一起造“在家无聊,来场激光打’病毒’
新冠病毒让大家挺闹心的,大家都希望病痛早点消停,武汉早日恢复平静祥和。既然没地方去,不如打打‘病毒’。效果是:当激光枪的激光束打到光敏电阻上,改变了光敏电阻预设的阈值时候,伺服电机会带动‘病毒’倒下,同时ISD录音模块被触发,发出哀嚎声。
ISO1820在连上线,并通电后,直接按REC按键,就可以录最大10秒的录音。按Play可以听录音效果。
https://v.youku.com/v_show/id_XNDUzODI0NTI2MA==.html?spm=a2h3j.8428770.3416059.1
==========================================
硬件使用如下:
1.arduino UNO
2.arduino sensor shield
3.9g 伺服
4.光敏电阻
5.ISD1820
6。激光模组
7.微动开关
============================
连线部分有两个,主模块的连线如下
激光枪连线如下
============================代码部分===============
/* made by gada888--------luoyang of China--2020-2------*/
#include <Servo.h>
Servo myservo; //name servo
int photocellPin = 0; //define photo cell reading input
int photocellReading; //define photo cell reading variable
int shadeOpen = 0;
int shadeClosed = 0;
#define PLAY_E 3 // pin 3 is used for playback-edge trigger
void setup()
{
Serial.begin(9600); //initiate serial @ 9600 baud
myservo.attach(11); //define pin 11 as servo signal pin
pinMode(PLAY_E,OUTPUT);
//digitalWrite(PLAY_E,LOW);
}
void loop()
{
Serial.print("Brightness = "); //print "Brightness = "
Serial.println(photocellReading); //print the photocell reading
photocellReading = analogRead(photocellPin); //define photocellReading as pin 0 input from LDR
photocellReading = map(photocellReading, 0, 1023, 0, 179); //map the LDR input to a value between 1-180 so the servo can understand it
{
if (photocellReading <= 75 && shadeClosed == 0) //if the LDR is showing darkness and the shade isn't closed already
{
myservo.write(0); //then tell the servo to rotate forwards at a steady rate (close shade)
//delay(1000); //2.5 second delay while shade is closing
digitalWrite(PLAY_E,LOW);
}
else if (photocellReading >= 75 && photocellReading <= 150) //if the LDR senses neither new light or new dark (mid-day)
{
myservo.write(50); //stop servo
digitalWrite(PLAY_E,HIGH);
}
delay(500);
}
}==========照片部分===============
老师,加个2020,参加活动吧。{:6_214:} rzyzzxw 发表于 2020-2-9 11:10
老师,加个2020,参加活动吧。
谢提醒,已添加2020. 牛,学习中 看起来简单的作品,实际要费不少心思呢{:6_213:} 多谢分享,学习了。 锂电池怎么充电 20060606 发表于 2020-8-5 06:06
锂电池怎么充电
DF商城有锂电池充电板,有3.7v的和7.4v的。
页:
[1]