SHARE
TWEET

Untitled

a guest May 11th, 2014 136 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. int myKeyDot=7;
  3. int myKeyDash=8;
  4.  
  5. int delayDot=120;
  6. int delayDash= 3 * delayDot;
  7.  
  8. int delayLetter = 3 * delayDot;
  9. int delayWord = 7 * delayDot;
  10.  
  11. int spaceDelay = 100;
  12.  
  13. int valDot = 0;
  14. int valDash = 0;
  15.  
  16. int oldValDot = 0;
  17. int oldValDash = 0;
  18.  
  19. int myTone=440;
  20.  
  21. int myPiezoPin = 11;
  22.  
  23. void setup() {
  24.  
  25.   pinMode(myKeyDot, INPUT);
  26.   pinMode(myKeyDash, INPUT);
  27.  
  28.   // initialize the serial communication:
  29.   Serial.begin(9600);
  30.   Serial.println("Start");
  31.  
  32. }
  33.  
  34. void loop() {
  35.  
  36.  
  37.   valDot=digitalRead(myKeyDot);
  38.   valDash=digitalRead(myKeyDash);
  39.  
  40.   if(valDot != oldValDot){
  41.     oldValDot = valDot;
  42.     if(valDot){
  43.       Serial.println("Dot");
  44.       tone(myPiezoPin, myTone, delayDot);
  45.       delay(delayDot);
  46.  
  47.     }
  48.   }
  49.  
  50.   if(valDash != oldValDash){
  51.     oldValDash = valDash;
  52.     if(valDash){
  53.       Serial.println("Dash");
  54.       tone(myPiezoPin, myTone, delayDash);
  55.       delay(delayDash);
  56.     }
  57.   }
  58.  
  59. }
RAW Paste Data
Want to get better at C?
Learn to code C in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top