Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- gnampSOS
- Using for example a vibration motor from a mobile phone in conjunction with an
- arduino running this basic sketch, a person in distress can summon
- help. Uses digital pins 13 and GND.
- The motor (or whatever) repeatedly relays an SOS signal in Morse code:-
- "... - - - ..."
- This could be effected by eg. placing the motor module against metal piping
- (ala 'prisoner telegraph').
- Dominic McGough 26th February 2012
- */
- void setup() {
- // initialize the digital pin as an output.
- // Pin 13 has an LED connected on most Arduino boards:
- pinMode(13, OUTPUT);
- }
- void loop() {
- digitalWrite(13, HIGH); // turn the motor/whatever on
- delay(200); // leave it on to make the first 'dot' of 'S'
- digitalWrite(13, LOW); // turn the motor/whatever off
- delay(70); // the first pause between dots
- digitalWrite(13, HIGH); // turn the motor/whatever on
- delay(200); // leave it on to make the second 'dot' of 'S'
- digitalWrite(13, LOW); // turn the motor/whatever off
- delay(70); // the second pause between dots
- digitalWrite(13, HIGH); // turn the motor/whatever on
- delay(200); // leave it on to make the third 'dot' of 'S'
- digitalWrite(13, LOW); // turn the motor/whatever off
- delay(400); // the pause between letters
- digitalWrite(13, HIGH); // turn the motor/whatever on
- delay(315); // leave it on to make the first 'dash' of 'O'
- digitalWrite(13, LOW); // turn the motor/whatever off
- delay(200); // the first pause between dashes
- digitalWrite(13, HIGH); // turn the motor/whatever on
- delay(315); // leave it on to make the second 'dash' of 'O'
- digitalWrite(13, LOW); // turn the motor/whatever off
- delay(200); // the second pause between dashes
- digitalWrite(13, HIGH); // turn the motor/whatever on
- delay(315); // leave it on to make the third 'dash' of 'O'
- digitalWrite(13, LOW); // turn the motor/whatever off
- delay(400); // the pause between letters
- digitalWrite(13, HIGH); // turn the motor/whatever on
- delay(200); // leave it on to make the first 'dot' of 'S'
- digitalWrite(13, LOW); // turn the motor/whatever off
- delay(70); // the first pause between dots
- digitalWrite(13, HIGH); // turn the motor/whatever on
- delay(200); // leave it on to make the second 'dot' of 'S'
- digitalWrite(13, LOW); // turn the motor/whatever off
- delay(70); // the second pause between dots
- digitalWrite(13, HIGH); // turn the motor/whatever on
- delay(200); // leave it on to make the third 'dot' of 'S'
- digitalWrite(13, LOW); // turn the motor/whatever off
- delay(2000); // a 2 second pause between 'SOS's
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement