4632| 7
|
[项目] [2020]'春节宅家一起造“在家无聊,来场激光打’病毒’ |
新冠病毒让大家挺闹心的,大家都希望病痛早点消停,武汉早日恢复平静祥和。既然没地方去,不如打打‘病毒’。 效果是:当激光枪的激光束打到光敏电阻上,改变了光敏电阻预设的阈值时候,伺服电机会带动‘病毒’倒下,同时ISD录音模块被触发,发出哀嚎声。 ISO1820在连上线,并通电后,直接按REC按键,就可以录最大10秒的录音。按Play可以听录音效果。 ========================================== 硬件使用如下: 1.Arduino UNO 2.arduino sensor shield 3.9g 伺服 4.光敏电阻 5.ISD1820 6。激光模组 7.微动开关 ============================ 连线部分有两个,主模块的连线如下 激光枪连线如下 ============================代码部分=============== [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]==========照片部分=============== |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed