Difference between revisions of "Smoke detector"
Jump to navigation
Jump to search
Line 8: | Line 8: | ||
void setup() { |
void setup() { |
||
− | Serial.begin(9600); |
+ | Serial.begin(9600); // open the serial port at 9600 bps: |
} |
} |
||
Line 16: | Line 16: | ||
for(i=0;i<100;i++) { |
for(i=0;i<100;i++) { |
||
val += analogRead(analogPin); // read the input pin |
val += analogRead(analogPin); // read the input pin |
||
− | delay(10); // delay |
+ | delay(10); // delay 10 milliseconds |
} |
} |
||
if(val>500) { |
if(val>500) { |
||
− | Serial.println("SMOKE"); // |
+ | Serial.println("SMOKE"); // output |
} |
} |
||
} |
} |
Revision as of 15:01, 19 April 2011
En France, les détecteurs de fumée deviennent obligatoires. Les premiers prix démarrent à 5 euros batterie de 9V incluse dans les magasins de bricolage. Il est possible de les rendre communiquant en les bricolant très légèrement et en les branchant sur un Arduino ou un MSP430.
Les informations récuperables sont le niveau de batterie (utilisez un pont diviseur ! la pile a une tension de 9V) et la présence de fumée en recuperant le tension envoyé sur le buzzer. Il est même possible de faire sonner le buzzer (attention les oreilles) en court-circuitant le bouton de test.
Voici le programme Arduino pour le buzzer en photo ci-dessous
int analogPin = 3; // buzzer wires connected to analog pin 3 and GND void setup() { Serial.begin(9600); // open the serial port at 9600 bps: } void loop() { int i=0; int val=0; for(i=0;i<100;i++) { val += analogRead(analogPin); // read the input pin delay(10); // delay 10 milliseconds } if(val>500) { Serial.println("SMOKE"); // output } }