

小伙伴们愚人节快乐!为了给愚人节加点料,今天我们来一发恶作剧道具,抛砖引玉。
这是一款机智的恶作剧加农炮,配备人体热释电传感器、3D打印的炮筒、填充好碎纸片作为“炮弹”,一旦有人路过,将会带给他突如其来的惊喜!
▼ 效果展示
所需的组件清单
-
5V 稳压器 × 1
-
公对公跳线若干
-
公对母跳线若干
-
12V 600mA 电源适配器 × 1
-
人体热释电传感器 × 1
-
伺服电机 - 通用合金齿轮(微型尺寸) × 1
-
0.1uF 陶瓷电容器 × 1
-
TO-220 散热器 × 1
-
1uF/25V 电解电容器 × 1
-
Arduino Uno R3 × 1
-
面包板 × 1
-
USB AB转接线 × 1
-
3D打印机 × 1
因为这是个开源项目,所以你也可以制作一个或加以改造!
可按照原理图组装机械控制部分,

再3D打印出文件库中的3D模型资源完成炮身的组装。



/* This code sets up the essentials for your circuit to work. It runs first every time your circuit is powered with electricity. */
void setup() {
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
Serial.begin(9600);
Serial.println("start");
servo.attach(SERVO_PIN);
servo.write(servoRestPosition);
delay(100);
servo.detach();
}
/* This code is the main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop. */
void loop() {
if (pir.read())
{
// The servo will rotate to target position and back to resting position with an interval of 500 milliseconds (0.5 seconds)
servo.attach(SERVO_PIN); // 1. attach the servo to correct pin to control it.
servo.write(servoTargetPosition); // 2. turns servo to target position. Modify target position by modifying the 'ServoTargetPosition' definition above.
delay(500); // 3. waits 500 milliseconds (0.5 sec). change the value in the brackets (500) for a longer or shorter delay in milliseconds.
servo.write(servoRestPosition); // 4. turns servo back to rest position. Modify initial position by modifying the 'ServoRestPosition' definition above.
delay(500); // 5. waits 500 milliseconds (0.5 sec). change the value in the brackets (500) for a longer or shorter delay in milliseconds.
servo.detach(); // 6. release the servo to conserve power. When detached the servo will NOT hold it's position under stress.
}
}Binary file (no preview)
给 Arduino 烧写文件库中的 C 代码的时候,注意代码中的SERVO_PIN和servoTargetPosition需要根据实际情况修改为相应的值,再加以调试即可!
Enjoy 愚人节的乐趣吧!
原文链接:https://www.hackster.io/circuito-io-team/motion-triggered-confetti-cannon-fcaaa9
译文首发于趣无尽,翻译cherry
硬件军火库
项目可用到的主板👆
大家有什么想法,或是对文章的指正,都欢迎在下方留言!
往期回顾
点击阅读👆

