Advertisement
computermuseo

sensore fiamma arduino (flame sensor)

Apr 16th, 2015
4,019
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. int max=20;
  2. void setup() {
  3. pinMode(3,OUTPUT);
  4. pinMode(9,OUTPUT);
  5. digitalWrite(7,LOW);
  6. }
  7. void loop() {
  8. if(analogRead(A0)>=max){
  9. alarm();
  10. flash();
  11. digitalWrite(9,HIGH);
  12. }
  13. else{
  14. digitalWrite(9,LOW);
  15. }
  16. }
  17. void alarm(){
  18. tone(4,400,500);
  19. delay(500);
  20. tone(4,650,500);
  21. delay(500);
  22. }
  23. void flash(){
  24. digitalWrite(3,HIGH);
  25. delay(50);
  26. digitalWrite(3,LOW);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement