Sunday 13 December 2015

Car Smoke Machine Pt 3

This is the final part of an on-going series of posts about a project to build and install a smoke machine in my car... for science or something...

If you missed the first two parts, they can be found here

So far we've got an e-Cigarette and an air pump wired together to produce a cloud of smoke. Now what we need is to find a way to control it and install it covertly in my car.

I don't want the trap to spring too early, I need to give them time to get comfortable in the car and get started, for it to be believable.

Also, the motor driver chip will need some logic control, so it makes sense to use a microcontroller to provide the logic and the timings.

As I mentioned in the previous post, left to it's own devices, the eCig's coil gets rather hot, so in order to counter that I wanted the microcontroller to only switch it on in 5 second bursts, then wait 5 seconds for it to cool down.

I used an ATTiny26, for no technical reason other than I have a lot of them spare.


Microcontroller code

 1 #define F_CPU 1000000UL
 2 
 3 #include <avr/io.h>
 4 #include <util/delay.h>
 5 
 6 #define CONTROL_PORT           PORTA
 7 #define output_low(port,pin)   port &= ~(1<<pin)
 8 #define output_high(port,pin)  port |= (1<<pin)
 9 #define delay(a)               _delay_ms(a)
10 #define smokeEnable            PA2
11 #define setInput(ddr,pin)      ddr &= ~(1 << pin)
12 #define isInputHigh(pinr,pin)  pinr & (1<<pin)
13 
14 int isRunning = 0;
15 int secCount = 0;
16 
17 int main(void) {
18     setup();
19     while (1) { loop(); }
20 }
21 
22 void setup() {
23     DDRA = 0xFF;  // all outputs
24     setInput(DDRB, PB6);
25 }
26 
27 void loop() {
28         if (isInputHigh(PINB, PA6)) {
29                 if (!isRunning) {
30                         delay(10000);
31                         output_high(CONTROL_PORT, smokeEnable);
32                         isRunning = 1;
33                 } else {
34                         secCount++;
35                         if (secCount > 5) {
36                                 output_low(CONTROL_PORT, smokeEnable);
37                                 delay(5000);
38                                 secCount = 0;
39                                 output_high(CONTROL_PORT, smokeEnable);
40                         }
41                 }
42         } else {
43                 output_low(CONTROL_PORT, smokeEnable);
44                 isRunning = 0;
45         }
46         delay(1000);
47 }
48 


The finished circuit
Click to enlarge
The Videos
I was hoping to use this to prank as many people as possible, and get some good video footage, but unfortunately only 2 of the videos were really usable. The first, is Craigs "We're all gonna die lads!" reaction, and the second, is Bethany's obliviousness to the cloud of smoke forming around her. Enjoy.





No comments:

Post a Comment