Advertisement
gnamp

Arduino gnampSOS

Feb 27th, 2012
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. /*
  2. gnampSOS
  3.  
  4. Using for example a vibration motor from a mobile phone in conjunction with an
  5. arduino running this basic sketch, a person in distress can summon
  6. help. Uses digital pins 13 and GND.
  7.  
  8. The motor (or whatever) repeatedly relays an SOS signal in Morse code:-
  9.  
  10. "... - - - ..."
  11.  
  12. This could be effected by eg. placing the motor module against metal piping
  13. (ala 'prisoner telegraph').
  14.  
  15. Dominic McGough 26th February 2012
  16.  
  17. */
  18.  
  19. void setup() {
  20. // initialize the digital pin as an output.
  21. // Pin 13 has an LED connected on most Arduino boards:
  22. pinMode(13, OUTPUT);
  23. }
  24.  
  25. void loop() {
  26. digitalWrite(13, HIGH); // turn the motor/whatever on
  27. delay(200); // leave it on to make the first 'dot' of 'S'
  28. digitalWrite(13, LOW); // turn the motor/whatever off
  29. delay(70); // the first pause between dots
  30. digitalWrite(13, HIGH); // turn the motor/whatever on
  31. delay(200); // leave it on to make the second 'dot' of 'S'
  32. digitalWrite(13, LOW); // turn the motor/whatever off
  33. delay(70); // the second pause between dots
  34. digitalWrite(13, HIGH); // turn the motor/whatever on
  35. delay(200); // leave it on to make the third 'dot' of 'S'
  36. digitalWrite(13, LOW); // turn the motor/whatever off
  37. delay(400); // the pause between letters
  38.  
  39. digitalWrite(13, HIGH); // turn the motor/whatever on
  40. delay(315); // leave it on to make the first 'dash' of 'O'
  41. digitalWrite(13, LOW); // turn the motor/whatever off
  42. delay(200); // the first pause between dashes
  43. digitalWrite(13, HIGH); // turn the motor/whatever on
  44. delay(315); // leave it on to make the second 'dash' of 'O'
  45. digitalWrite(13, LOW); // turn the motor/whatever off
  46. delay(200); // the second pause between dashes
  47. digitalWrite(13, HIGH); // turn the motor/whatever on
  48. delay(315); // leave it on to make the third 'dash' of 'O'
  49. digitalWrite(13, LOW); // turn the motor/whatever off
  50. delay(400); // the pause between letters
  51.  
  52. digitalWrite(13, HIGH); // turn the motor/whatever on
  53. delay(200); // leave it on to make the first 'dot' of 'S'
  54. digitalWrite(13, LOW); // turn the motor/whatever off
  55. delay(70); // the first pause between dots
  56. digitalWrite(13, HIGH); // turn the motor/whatever on
  57. delay(200); // leave it on to make the second 'dot' of 'S'
  58. digitalWrite(13, LOW); // turn the motor/whatever off
  59. delay(70); // the second pause between dots
  60. digitalWrite(13, HIGH); // turn the motor/whatever on
  61. delay(200); // leave it on to make the third 'dot' of 'S'
  62. digitalWrite(13, LOW); // turn the motor/whatever off
  63. delay(2000); // a 2 second pause between 'SOS's
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement