[2020]'春节宅家一起造“在家无聊,来场激光打’病毒’

2020-02-091.5万
AI 快速预览详细 收起
这个项目名为“激光打病毒”,使用Arduino UNO、ISD1820录音模块、光敏电阻、9g伺服电机等硬件。当激光枪的激光束打到光敏电阻上,改变了光敏电阻预设的阈值时,伺服电机会带动‘病毒’倒下,同时ISD录音模块被触发,发出哀嚎声。这是一个适合亲子共学的创意项目,可以激发孩子对编程和科学的兴趣。
新冠病毒让大家挺闹心的,大家都希望病痛早点消停,武汉早日恢复平静祥和。既然没地方去,不如打打‘病毒’。

效果是:当激光枪的激光束打到光敏电阻上,改变了光敏电阻预设的阈值时候,伺服电机会带动‘病毒’倒下,同时ISD录音模块被触发,发出哀嚎声。
ISO1820在连上线,并通电后,直接按REC按键,就可以录最大10秒的录音。按Play可以听录音效果。


==========================================
硬件使用如下:

1.Arduino UNO
[2020]
2.arduino sensor shield
[2020]
3.9g 伺服
[2020]
4.光敏电阻
[2020]
5.ISD1820
[2020]
6。激光模组
[2020]
7.微动开关

============================
连线部分有两个,主模块的连线如下
[2020]
激光枪连线如下
[2020]============================代码部分===============

[mw_shl_code=applescript,false]/* 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);
  
}
}[/mw_shl_code]==========照片部分===============
[2020]
[2020][2020]







创作许可协议

本项目采用 None(不开放任何权利,保留所有权利) 进行许可。

评论(5)
20060606
20060606
锂电池怎么充电
gada888
gada888
作者
回复20060606
DF商城有锂电池充电板,有3.7v的和7.4v的。
kylinpoet
kylinpoet
多谢分享,学习了。
且歌且行
且歌且行
看起来简单的作品,实际要费不少心思呢
DFrJ5KYVQaH
DFrJ5KYVQaH
牛,学习中
rzyzzxw
rzyzzxw
老师,加个2020,参加活动吧。
gada888
gada888
作者
回复rzyzzxw
谢提醒,已添加2020.
- 没有更多了 -