book collections email follower instructable user

Step 16: SOAP Code

The principle of the SOAP code is as follows:

1. Initialise variables including the start and end addresses of each audio clip.

2. Detect which wash programme LED is illuminated.

3. Set Start and End address for the audio clip associated with the selected wash programme.

4. Play the relevant audio clip.

5. Wait 3 seconds.

6. Repeat from step 2.

The Arduino ino file is attached. This should be uploaded to the UNO R3.

The text of the code is as follows:

SOAP Arduino Code

  1. // SOAP - Speech Output Announcing Programs
  2. // Talking Washing Machine Interface for the Blind
  3. //
  4. #include < ISD1700.h > // Library for Audio Shield (downloaded from Velleman website)
  5. ISD1700 chip(10); // Initialise chipcorder with SS at Arduino's digital pin 10
  6. //
  7. // Initialise Audio Shield variables
  8. int apc=0;
  9. int vol=0; //volume 0=MAX, 7=min
  10. int startAddr=0x10; //Start address of Audio Shield RAM
  11. int endAddr =0x2DF; //End address of Audio Shield RAM
  12. //
  13. //Set Wash Programme Audio Clips start and end addresses determined from tests
  14. int startAddr1=0x010; int endAddr1 =0x020; //Wash Programme 1 Cotton
  15. int startAddr2=0x025; int endAddr2 =0x03E; //Wash Programme 2 Eco Cotton
  16. int startAddr3=0x03F; int endAddr3 =0x054; //Wash Programme 3 Synthetics
  17. int startAddr4=0x056; int endAddr4 =0x066; //Wash Programme 4 Wool
  18. int startAddr5=0x068; int endAddr5 =0x078; //Wash Programme 5 Spin
  19. int startAddr6=0x078; int endAddr6 =0x090; //Wash Programme 6 Rinse + Spin
  20. int startAddr7=0x090; int endAddr7 =0x0AE; //Wash Programme 7 Eco Drum Clean
  21. int startAddr8=0x0AE; int endAddr8 =0x0CE; //Wash Programme 8 Super Eco Wash
  22. int startAddr9=0x0CE; int endAddr9 =0x0EE; //Wash Programme 9 15 Minute Quick Wash
  23. int startAddr10=0x0EE; int endAddr10 =0x105; //Wash Programme 10 Daily Wash
  24. int startAddr11=0x105; int endAddr11 =0x120; //Wash Programme 11 Delicates
  25. int startAddr12=0x123; int endAddr12 =0x133; //Wash Programme 12 Dark Garment
  26. int startAddr13=0x136; int endAddr13 =0x148; //Wash Programme 13 Bedding
  27. int startAddr14=0x149; int endAddr14 =0x167; //Wash Programme 14 Baby Care
  28. //
  29. const int inputPin2 = 2; // Digital inputs. DI 10 used by Audio Shield so cannot be used for sensor input
  30. const int inputPin3 = 3;
  31. const int inputPin4 = 4;
  32. const int inputPin5 = 5;
  33. const int inputPin6 = 6;
  34. const int inputPin7 = 7;
  35. const int inputPin8 = 8;
  36. const int inputPin9 = 9;
  37. const int inputPinA0 = 14; //Analogue inputs used as Digital Inputs
  38. const int inputPinA1 = 15;
  39. const int inputPinA2 = 16;
  40. const int inputPinA3 = 17;
  41. const int inputPinA4 = 18;
  42. const int inputPinA5 = 19;
  43. //
  44. // Define variables
  45. // for storing the state of the inputs
  46. // Inputs initialised HIGH as sensor input pulls the input LOW
  47. int inputState_Baby_Care = 1;
  48. int inputState_Eco_Drum_Clean = 1;
  49. int inputState_Rinse_and_Spin = 1;
  50. int inputState_Spin = 1;
  51. int inputState_Wool = 1;
  52. int inputState_Cotton = 1;
  53. int inputState_Eco_Cotton = 1;
  54. int inputState_Synthetics = 1;
  55. int inputState_Daily_Wash = 1;
  56. int inputState_15_Minute_Quick_Wash = 1;
  57. int inputState_Super_Eco_Wash = 1;
  58. int inputState_Delicates = 1;
  59. int inputState_Dark_Garment = 1;
  60. int inputState_Bedding = 1;
  61. //
  62. //
  63. // Setup
  64. void setup()
  65. {
  66. //
  67. //Initialise Audio Shield
  68. apc = apc | vol; // D0, D1, D2
  69. apc = apc | 0x100; // D8 SPK OFF, comment enable SPK
  70. apc = apc | 0x800; // D11 EOM ON, comment disable EOM
  71. //
  72. // initialize the pins as inputs:
  73. pinMode(inputPin2, INPUT);
  74. pinMode(inputPin3, INPUT);
  75. pinMode(inputPin4, INPUT);
  76. pinMode(inputPin5, INPUT);
  77. pinMode(inputPin6, INPUT);
  78. pinMode(inputPin7, INPUT);
  79. pinMode(inputPin8, INPUT);
  80. pinMode(inputPin9, INPUT);
  81. pinMode(inputPinA0, INPUT);
  82. pinMode(inputPinA1, INPUT);
  83. pinMode(inputPinA2, INPUT);
  84. pinMode(inputPinA3, INPUT);
  85. pinMode(inputPinA4, INPUT);
  86. pinMode(inputPinA5, INPUT);
  87. }
  88. //
  89. // Main Loop
  90. void loop()
  91. {
  92. //
  93. chip.pu(); //Chip Power Up
  94. //
  95. // Read the states of the inputs. Only one will be low:
  96. inputState_Baby_Care = digitalRead(inputPin2);
  97. inputState_Eco_Drum_Clean = digitalRead(inputPin3);
  98. inputState_Rinse_and_Spin = digitalRead(inputPin4);
  99. inputState_Spin = digitalRead(inputPin5);
  100. inputState_Wool = digitalRead(inputPin6);
  101. inputState_Cotton = digitalRead(inputPin7);
  102. inputState_Eco_Cotton = digitalRead(inputPin8);
  103. inputState_Synthetics = digitalRead(inputPin9);
  104. inputState_Daily_Wash = digitalRead(inputPinA0);
  105. inputState_15_Minute_Quick_Wash = digitalRead(inputPinA1);
  106. inputState_Super_Eco_Wash = digitalRead(inputPinA2);
  107. inputState_Delicates = digitalRead(inputPinA3);
  108. inputState_Dark_Garment = digitalRead(inputPinA4);
  109. inputState_Bedding = digitalRead(inputPinA5);
  110. //
  111. // Set correct start and end address for the relevant audio clip
  112. // based on which programme LED is illuminated
  113. // InputState is LOW for an illuminated LED
  114. if (inputState_Baby_Care == LOW)
  115. {chip.set_play(startAddr14,endAddr14); }
  116. if (inputState_Eco_Drum_Clean == LOW)
  117. {chip.set_play(startAddr7,endAddr7); }
  118. if (inputState_Rinse_and_Spin == LOW)
  119. {chip.set_play(startAddr6,endAddr6); }
  120. if (inputState_Spin == LOW)
  121. {chip.set_play(startAddr5,endAddr5); }
  122. if (inputState_Wool == LOW)
  123. {chip.set_play(startAddr4,endAddr4); }
  124. if (inputState_Cotton == LOW)
  125. {chip.set_play(startAddr1,endAddr1); }
  126. if (inputState_Eco_Cotton == LOW)
  127. {chip.set_play(startAddr2,endAddr2); }
  128. if (inputState_Synthetics == LOW)
  129. {chip.set_play(startAddr3,endAddr3); }
  130. if (inputState_Daily_Wash == LOW)
  131. {chip.set_play(startAddr10,endAddr10);}
  132. if (inputState_15_Minute_Quick_Wash == LOW)
  133. {chip.set_play(startAddr9,endAddr9); }
  134. if (inputState_Super_Eco_Wash == LOW)
  135. {chip.set_play(startAddr8,endAddr8); }
  136. if (inputState_Delicates == LOW)
  137. {chip.set_play(startAddr11,endAddr11); }
  138. if (inputState_Dark_Garment == LOW)
  139. {chip.set_play(startAddr12,endAddr12); }
  140. if (inputState_Bedding == LOW)
  141. {chip.set_play(startAddr13,endAddr13); }
  142. //
  143. {chip.play();} // Play the clip
  144. //
  145. delay(3000); //Wait 3 seconds before repeating loop
  146. //
  147. }