Arduino Dishwasher

Arduino Dishwasher

This is my first post of many which I intend to write, so why not start with something complicated?.

In this occasion I will tell you step by step the electronic design  of a dishwasher using arduino. I have only seen one project finished of a dishwasher using arduino of which a took some lines of codes for the temperature sensor, which in their turn was taken from arduino playground. This is the page of the other dishwasher. http://www.neonsquirt.com/dishwasher.html

The history of the Riveratek dishwasher with arduino.

I took the dishwasher of a friend’s mother that was broken, of the Brand Atlas model. DM4506 these dishwashers are chinese and there isn’t much information about them, I could only find the owners manual in swedish.

My idea was to fix it and return it to it’s owner without charging for the labour, of the reparation her son would only pay the material used. Therefore when the dischwasher was delivered to my home the first thing I did was checking the fault and fortunately the fault was the electronic board, I say fortunately because if it had been something else, this project would not have come to exist.

I tried obtaining the circuit board without any luck, so this was when I decided to make the board with an arduino.

Let’s get started (RiveraTek dishwasher with arduino).

When thinking of the materials  that I would use and how the project would be, I decided to use a prototyping PCB board to make the relay circuit board, I choose to use small relays with an adecuated amperaje for the function of the dishwasher, these would be controlled by an arduino pro mini and to be visualised by an lcd screen.


The first thing I did was  to disassembly the original electronic board to later take some pieces and re-use.

The relays should control 6 devices of the dishwasher: Drain pump, wash pump, let in valve, soap solenoid, regeneration solenoid and heather.

The other 8 devices that the dishwasher has I was thinking about connecting in diverse ways to the arduino but for some fault in my programmation or something that I never understood I only connected 7 of the 8 mentioned: Door switch, program select key, start button, fill sensor, temperature sensor, lcd screen. The missing device and that gave me some problems was the (security device of the dishwasher which I used as a current switch).

So I got to work and started to design what the board should look like with the relays, and I made them fit above a plastic that was from the original board and this was the result.


After this I dedicated myself making the conductive tracks on the board and putting terminals to be able to make the connections towards the arduino. I also used a switching power supply of 5V 2A to supply the relays and the arduino.

After I made the connection of the lcd to the arduino and started making the program commencing with the display, select key, start button  and thermometer (for this I used the same termistor that came with the dishwasher a 10k NTC).
Not forgetting the hole that would be placed on the front of the dishwasher for the lcd where an acrylic rectangle was placed which was cut out previously.

I connected all the relays to their respective device, performing tests with the limited programming that it had,  this was a little uncomfortable because I had to do it in the kitchen and I have no dishwasher connection, from the tap I had to use an adaptor to connect the water hose, I also used a wooden chair as a working bench and the most uncomfortable part was working on the floor.


After seeing that all the relays were working and the devices were functioning well, I decided to mount all the curcuits in the front panel of the dishwasher.

For the circuit I left some terminals for future updates.

This is the finished dishwasher without the front lid but it’s 100% working.
  1. //Dishwasher v.1.0.
  2. //Programer: Pedro Rivera.
  3. //Program to arduino duemillanove o mini arduino pro.
  4. //A dishwasher controller with 5 different wash programs,
  5. //temperature control thermistor 10k.
  6. //6 relay control opto-isolator
  7. //Licensed under Creative Commons.
  8. #include <math.h>
  9. #include <LiquidCrystal.h>
  10. //Pin assignment
  11. LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
  12. #define doorBtn 2 //door button
  13. #define errorSens 3 //overfill sensor error
  14. #define drainPump 4 //drain pump
  15. #define soapSolen 5 //Solenoid soap dispenser
  16. #define inletValve 6 //water inlet valve
  17. #define regenSolen 7 //regeneration solenoid
  18. #define keySelect A0 //select key
  19. #define startBtn A1 //start button
  20. #define fillSens A2 //fill sensor
  21. #define tempSensor A3 //temperature sensor
  22. #define heater A4 //heater
  23. #define washPump A5 //washpump
  24. //constants declaration
  25. const int btnStrong = 1;
  26. const int btnNormal = 2;
  27. const int btnEconom = 3;
  28. const int btnFast = 4;
  29. const int btnRinse = 5;
  30. const int btnNone = 6;
  31. //variables declaration
  32. unsigned long periodStart, periodFinished, periodElapsed;
  33. unsigned long periodStart2, periodFinished2, periodElapsed2;
  34. volatile int doorBtnState = 0;
  35. double tempArray[25];
  36. byte arrayIndex = 0;
  37. int lcdKeyMenu = 0;
  38. int selKeyIN = 0;
  39. int startBtnState = 0;
  40. int fillSensState = 0;
  41. int tempLimit = 57;
  42. int x = 0;
  43. //actions
  44. int readKey(){ //read startup programs select key
  45. selKeyIN = analogRead(keySelect); //read the value from the sensor
  46. if (selKeyIN < 300) return btnRinse;
  47. if (selKeyIN < 500) return btnEconom;
  48. if (selKeyIN < 600) return btnNormal;
  49. if (selKeyIN < 700) return btnStrong;
  50. if (selKeyIN < 999) return btnFast; return btnNone; }
  51. double waterTemp() { //subroutine taken from www.neonsquirt.com/
  52. if (arrayIndex> 23) {//which in its turn was taken from Arduino Playground
  53. arrayIndex=0;
  54. }
  55. else {
  56. arrayIndex++;
  57. }
  58. double Temp; // The Thermistor2 "Simple Code"
  59. int RawADC = analogRead(tempSensor);
  60. Temp = log(((10240000/RawADC) - 10000));
  61. Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
  62. Temp = Temp - 273.15; //convert kelvin to celsious
  63. tempArray[arrayIndex]=Temp;
  64. Temp=0;
  65. for (int i=0; i<24; i++) {
  66. Temp += tempArray[i];
  67. }
  68. return (Temp / 25); // return the average temperature of the array
  69. }
  70. void dispTemp(){
  71. lcd.setCursor(0,4);
  72. lcd.print("Temperature: ");
  73. lcd.print(int(waterTemp()));
  74. lcd.print((char)223);
  75. lcd.print("C ");
  76. }
  77. void Welcome(){
  78. lcd.clear();
  79. lcd.setCursor(0,0);
  80. lcd.print(" Welcome ");
  81. lcd.setCursor(0,1);
  82. lcd.print(" Dishwasher ");
  83. lcd.setCursor(0,2);
  84. lcd.print(" with Arduino ");
  85. lcd.setCursor(0,3);
  86. lcd.print(" RiveraTek Rev 1.0");
  87. delay(5000);
  88. lcd.clear();
  89. }
  90. void Finish(){
  91. lcd.clear();
  92. lcd.setCursor(0,0);
  93. lcd.print(" Clean dishes ");
  94. lcd.setCursor(0,1);
  95. lcd.print(" Press the off button ");
  96. lcd.setCursor(0,2);
  97. lcd.print(" for finish" );
  98. while (true){};
  99. }
  100. void selMenu(){
  101. lcd.setCursor(0,0);
  102. lcd.print(" Select ");
  103. lcd.setCursor(0,1);
  104. lcd.print(" a program ");
  105. lcd.setCursor(0,2);
  106. lcd.print(" and press start ");
  107. lcd.setCursor(0,3);
  108. lcd.print(" for initiate ");
  109. actStartBtn();
  110. }
  111. void actStartBtn(){ //start button action
  112. startBtnState = digitalRead(startBtn);
  113. while (startBtnState == HIGH){
  114. startBtnState = digitalRead(startBtn);
  115. }
  116. }
  117. void actDoorBtn() { // swich door action
  118. digitalWrite(heater, LOW);
  119. digitalWrite(washPump, LOW);
  120. digitalWrite(soapSolen, LOW);
  121. digitalWrite(drainPump, LOW);
  122. digitalWrite(inletValve, LOW);
  123. digitalWrite(regenSolen, LOW);
  124. doorBtnState = digitalRead(doorBtn);
  125. while (doorBtnState == HIGH){
  126. doorBtnState = digitalRead(doorBtn);
  127. }
  128. }
  129. void actErrorSens(){
  130. cli();
  131. digitalWrite(heater, LOW);
  132. digitalWrite(washPump, LOW);
  133. digitalWrite(soapSolen, LOW);
  134. digitalWrite(drainPump, LOW);
  135. digitalWrite(inletValve, LOW);
  136. digitalWrite(regenSolen, LOW);
  137. lcd.setCursor(0,0);
  138. lcd.print(" ERROR ");
  139. lcd.setCursor(0,1);
  140. lcd.print(" DISCONNECT ");
  141. lcd.setCursor(0,2);
  142. lcd.print(" THE DISHWASHER ");
  143. lcd.setCursor(0,3);
  144. lcd.print(" FROM SOCKET ");
  145. while (true){};
  146. }
  147. void actSoapSolenONE(){
  148. digitalWrite(soapSolen, HIGH);
  149. periodStart2 = millis();
  150. timeElapsed2();
  151. while(periodElapsed2 < 3000){
  152. timeElapsed2();
  153. }
  154. digitalWrite(soapSolen, LOW);
  155. }
  156. void actFill(){
  157. lcd.setCursor(0,2);
  158. lcd.print(" Filling ");
  159. digitalWrite(inletValve, HIGH);
  160. periodStart2 = millis();
  161. timeElapsed2();
  162. while(periodElapsed2 < 7000){
  163. digitalWrite(inletValve, HIGH);
  164. timeElapsed2();
  165. }
  166. digitalWrite(washPump, HIGH);
  167. digitalWrite(inletValve, HIGH);
  168. fillSensState = digitalRead(fillSens);
  169. while (fillSensState == LOW){
  170. digitalWrite(washPump, HIGH);
  171. digitalWrite(inletValve, HIGH);
  172. fillSensState = digitalRead(fillSens);
  173. }
  174. digitalWrite(washPump, HIGH);
  175. digitalWrite(inletValve, HIGH);
  176. periodStart2 = millis();
  177. timeElapsed2();
  178. while(periodElapsed2 < 10000){
  179. digitalWrite(inletValve, HIGH);
  180. digitalWrite(washPump, HIGH);
  181. timeElapsed2();
  182. }
  183. digitalWrite(inletValve, LOW);
  184. lcd.setCursor(0,2);
  185. lcd.print(" ");
  186. digitalWrite(washPump, HIGH);
  187. }
  188. void actDrainPumpON(){
  189. digitalWrite(drainPump, HIGH);
  190. lcd.setCursor(0,2);
  191. lcd.print("  Draining ");
  192. lcd.setCursor(0,3);
  193. lcd.print(" ");
  194. }
  195. void actDrainPumpOFF(){
  196. digitalWrite(drainPump, LOW);
  197. lcd.setCursor(0,2);
  198. lcd.print(" ");
  199. }
  200. void actDrain(){
  201. actDrainPumpON();
  202. fillSensState = digitalRead(fillSens);
  203. while (fillSensState == HIGH) {
  204. actDrainPumpON();
  205. fillSensState = digitalRead(fillSens);
  206. }
  207. actDrainPumpON();
  208. periodStart2 = millis();
  209. timeElapsed2();
  210. while(periodElapsed2 < 30000){
  211. actDrainPumpON();
  212. timeElapsed2();
  213. }
  214. actDrainPumpOFF();
  215. }
  216. void actHeaterON(){
  217. digitalWrite(heater, HIGH);
  218. }
  219. void actHeaterOFF(){
  220. digitalWrite(heater, LOW);
  221. }
  222. void actPreWashON(){
  223. digitalWrite(washPump, HIGH);
  224. lcd.setCursor(0,2);
  225. lcd.print(" Prewash ");
  226. }
  227. void actPreWashOFF(){
  228. digitalWrite(washPump, LOW);
  229. lcd.setCursor(0,2);
  230. lcd.print(" ");
  231. }
  232. void actWashON(){
  233. digitalWrite(washPump, HIGH);
  234. lcd.setCursor(0,2);
  235. lcd.print(" Washing ");
  236. }
  237. void actWashOFF(){
  238. digitalWrite(washPump, LOW);
  239. lcd.setCursor(0,2);
  240. lcd.print(" ");
  241. }
  242. void timeElapsed(){
  243. periodFinished= millis();
  244. periodElapsed = (periodFinished - periodStart);
  245. }
  246. void timeElapsed2(){
  247. periodFinished2 = millis();
  248. periodElapsed2 = (periodFinished2 - periodStart2);
  249. }
  250. void actRinse(){
  251. lcd.setCursor(0,1);
  252. lcd.print(" Rinse ");
  253. actFill();
  254. actWashON();
  255. periodStart = millis();
  256. timeElapsed();
  257. while(periodElapsed < 390000){
  258. actWashON();
  259. timeElapsed();
  260. }
  261. actWashOFF();
  262. pause();
  263. actDrain();
  264. }
  265. void actClearRinse(){
  266. lcd.setCursor(0,1);
  267. lcd.print(" Clear rinse ");
  268. actFill();
  269. actWashON();
  270. actHeaterON();
  271. while(waterTemp() < 48){
  272. actHeaterON();
  273. actWashON();
  274. dispTemp();
  275. }
  276. actWashON();
  277. actHeaterON();
  278. digitalWrite(soapSolen, HIGH);
  279. periodStart = millis();
  280. timeElapsed();
  281. while(periodElapsed < 60000){
  282. actWashON();
  283. actHeaterON();
  284. digitalWrite(soapSolen, HIGH);
  285. timeElapsed();
  286. }
  287. actWashON();
  288. actHeaterON();
  289. digitalWrite(soapSolen, LOW);
  290. periodStart = millis();
  291. timeElapsed();
  292. while(periodElapsed < 3000){
  293. actWashON();
  294. actHeaterON();
  295. digitalWrite(soapSolen, LOW);
  296. timeElapsed();
  297. }
  298. actWashON();
  299. actHeaterON();
  300. digitalWrite(soapSolen, HIGH);
  301. periodStart = millis();
  302. timeElapsed();
  303. while(periodElapsed < 60000){
  304. actWashON();
  305. actHeaterON();
  306. digitalWrite(soapSolen, HIGH);
  307. timeElapsed();
  308. }
  309. digitalWrite(soapSolen, LOW);
  310. actWashON();
  311. actHeaterON();
  312. while(waterTemp() < tempLimit){
  313. actHeaterON();
  314. actWashON();
  315. dispTemp();
  316. }
  317. actWashON();
  318. actHeaterOFF();
  319. periodStart = millis();
  320. timeElapsed();
  321. while(periodElapsed < 60000){
  322. actWashON();
  323. timeElapsed();
  324. }
  325. actWashOFF();
  326. pause();
  327. actDrain();
  328. }
  329. void actDry(){
  330. lcd.setCursor(0,1);
  331. lcd.print(" Secando ");
  332. periodStart = millis();
  333. timeElapsed();
  334. while(periodElapsed < 120000){
  335. timeElapsed();
  336. }
  337. digitalWrite(regenSolen, HIGH);
  338. actDrain();
  339. periodStart = millis();
  340. timeElapsed();
  341. while(periodElapsed < 60000){
  342. timeElapsed();
  343. }
  344. periodStart = millis();
  345. timeElapsed();
  346. while(periodElapsed < 1000){
  347. digitalWrite(inletValve, HIGH);
  348. timeElapsed();
  349. }
  350. digitalWrite(inletValve, LOW);
  351. periodStart = millis();
  352. timeElapsed();
  353. while(periodElapsed < 3000){
  354. timeElapsed();
  355. }
  356. periodStart = millis();
  357. timeElapsed();
  358. while(periodElapsed < 1000){
  359. digitalWrite(inletValve, HIGH);
  360. timeElapsed();
  361. }
  362. digitalWrite(inletValve, LOW);
  363. digitalWrite(regenSolen, LOW);
  364. actDrain();
  365. periodStart = millis();
  366. timeElapsed();
  367. while(periodElapsed < 660000){
  368. timeElapsed();
  369. }
  370. actDrain();
  371. }
  372. void pause(){
  373. periodStart = millis();
  374. timeElapsed();
  375. while(periodElapsed < 3000){
  376. timeElapsed();
  377. }
  378. }
  379. //programs
  380. void wStrong(){
  381. lcd.setCursor(0,0);
  382. lcd.print(" Intensive Wash ");
  383. lcd.setCursor(0,1);
  384. lcd.print(" ");
  385. lcd.setCursor(0,2);
  386. lcd.print(" ");
  387. lcd.setCursor(0,3);
  388. lcd.print(" ");
  389. actDrain();
  390. pause();
  391. actFill();
  392. pause();
  393. actPreWashON();
  394. while(waterTemp() < 36){
  395. actPreWashON();
  396. actHeaterON();
  397. dispTemp();
  398. }
  399. actHeaterOFF();
  400. periodStart = millis();
  401. timeElapsed();
  402. while(periodElapsed < 180000){
  403. actPreWashON();
  404. dispTemp();
  405. timeElapsed();
  406. }
  407. actPreWashOFF();
  408. pause();
  409. actDrain();
  410. pause();
  411. actFill();
  412. pause();
  413. actSoapSolenONE();
  414. while(waterTemp() < 59){
  415. actWashON();
  416. actHeaterON();
  417. dispTemp();
  418. }
  419. actHeaterOFF();
  420. periodStart = millis();
  421. timeElapsed();
  422. while(periodElapsed < 720000){
  423. actWashON();
  424. dispTemp();
  425. timeElapsed();
  426. }
  427. actWashOFF();
  428. pause();
  429. actDrain();
  430. pause();
  431. actRinse();
  432. pause();
  433. actRinse();
  434. pause();
  435. actClearRinse();
  436. pause();
  437. actDry();
  438. Finish();
  439. }
  440. void wNormal(){
  441. lcd.setCursor(0,0);
  442. lcd.print(" Normal Wash ");
  443. lcd.setCursor(0,1);
  444. lcd.print(" ");
  445. lcd.setCursor(0,2);
  446. lcd.print(" ");
  447. actDrain();
  448. pause();
  449. actFill();
  450. pause();
  451. actPreWashON();
  452. periodStart = millis();
  453. timeElapsed();
  454. while(periodElapsed < 360000){
  455. actPreWashON();
  456. dispTemp();
  457. timeElapsed();
  458. }
  459. actPreWashOFF();
  460. pause();
  461. actDrain();
  462. pause();
  463. actFill();
  464. pause();
  465. actSoapSolenONE();
  466. while(waterTemp() < 55){
  467. actWashON();
  468. actHeaterON();
  469. dispTemp();
  470. }
  471. actHeaterOFF();
  472. periodStart = millis();
  473. timeElapsed();
  474. while(periodElapsed < 840000){
  475. actWashON();
  476. dispTemp();
  477. timeElapsed();
  478. }
  479. actWashOFF();
  480. pause();
  481. actDrain();
  482. pause();
  483. actRinse();
  484. pause();
  485. actClearRinse();
  486. pause();
  487. actDry();
  488. Finish();
  489. }
  490. void wEconom(){
  491. lcd.setCursor(0,0);
  492. lcd.print(" Eco Wash ");
  493. lcd.setCursor(0,1);
  494. lcd.print(" ");
  495. lcd.setCursor(0,2);
  496. lcd.print(" ");
  497. actDrain();
  498. pause();
  499. actFill();
  500. pause();
  501. actPreWashON();
  502. periodStart = millis();
  503. timeElapsed();
  504. while(periodElapsed < 480000){
  505. actPreWashON();
  506. dispTemp();
  507. timeElapsed();
  508. }
  509. actPreWashOFF();
  510. pause();
  511. actDrain();
  512. pause();
  513. actFill();
  514. pause();
  515. actSoapSolenONE();
  516. while(waterTemp() < 41){
  517. actWashON();
  518. actHeaterON();
  519. dispTemp();
  520. }
  521. actHeaterOFF();
  522. periodStart = millis();
  523. timeElapsed();
  524. while(periodElapsed < 600000){
  525. actWashON();
  526. dispTemp();
  527. timeElapsed();
  528. }
  529. while(waterTemp() < 48){
  530. actWashON();
  531. actHeaterON();
  532. dispTemp();
  533. }
  534. actHeaterOFF();
  535. periodStart = millis();
  536. timeElapsed();
  537. while(periodElapsed < 30000){
  538. actWashON();
  539. dispTemp();
  540. timeElapsed();
  541. }
  542. actWashOFF();
  543. pause();
  544. actDrain();
  545. pause();
  546. actRinse();
  547. pause();
  548. actClearRinse();
  549. pause();
  550. actDry();
  551. Finish();
  552. }
  553. void wFast(){
  554. tempLimit = 48;
  555. lcd.setCursor(0,0);
  556. lcd.print(" Quick Wash ");
  557. lcd.setCursor(0,1);
  558. lcd.print(" ");
  559. lcd.setCursor(0,2);
  560. lcd.print(" ");
  561. actDrain();
  562. pause();
  563. actFill();
  564. pause();
  565. actSoapSolenONE();
  566. while(waterTemp() < 36){
  567. actWashON();
  568. actHeaterON();
  569. dispTemp();
  570. }
  571. actHeaterOFF();
  572. periodStart = millis();
  573. timeElapsed();
  574. while(periodElapsed < 240000){
  575. actWashON();
  576. dispTemp();
  577. timeElapsed();
  578. }
  579. actWashOFF();
  580. pause();
  581. actDrain();
  582. pause();
  583. actRinse();
  584. pause();
  585. actClearRinse();
  586. pause();
  587. actDry();
  588. Finish();
  589. }
  590. void wRinse(){
  591. lcd.setCursor(0,0);
  592. lcd.print(" Rinse ");
  593. lcd.setCursor(0,1);
  594. lcd.print(" ");
  595. lcd.setCursor(0,2);
  596. lcd.print(" ");
  597. actDrain();
  598. pause();
  599. actFill();
  600. pause();
  601. actPreWashON();
  602. periodStart = millis();
  603. timeElapsed();
  604. while(periodElapsed < 360000){
  605. actPreWashON();
  606. dispTemp();
  607. timeElapsed();
  608. }
  609. actPreWashOFF();
  610. pause();
  611. actDrain();
  612. pause();
  613. actDry();
  614. Finish();
  615. }
  616. void setup() {
  617. for (int i=0; i<25; i++) tempArray[i]=21; //first read temperature
  618. lcd.begin(20,4);
  619. pinMode(heater, OUTPUT);
  620. pinMode(washPump, OUTPUT);
  621. pinMode(soapSolen, OUTPUT);
  622. pinMode(regenSolen, OUTPUT);
  623. pinMode(drainPump, OUTPUT);
  624. pinMode(inletValve, OUTPUT);
  625. digitalWrite(startBtn, HIGH);
  626. digitalWrite(fillSens, HIGH);
  627. digitalWrite(washPump, LOW);
  628. digitalWrite(drainPump, LOW);
  629. digitalWrite(inletValve, LOW);
  630. attachInterrupt(0, actDoorBtn, RISING);
  631. //attachInterrupt(1, actErrorSens, RISING);
  632. }
  633. void loop(){
  634. Welcome();
  635. selMenu();
  636. lcdKeyMenu = readKey(); // read key
  637. switch (lcdKeyMenu) {
  638. case 1:
  639. wStrong();
  640. break;
  641. case 2:
  642. wNormal();
  643. break;
  644. case 3:
  645. wEconom();
  646. break;
  647. case 4:
  648. wFast();
  649. break;
  650. case 5:
  651. wRinse();
  652. break;
  653. }
  654. }

9 thoughts on “Arduino Dishwasher

  1. Hi! I also installed arduino 1.0.1; found the liquidcristal lcd library;and not find anywhere the math.h library; during compiling the sketch found some error messages
    line :52: error: expected unqualified-id before ‘else’
    line :57: error: expected constructor,destructor or type conversion before ‘=’ token
    line:58: error: expected constructor,destructor or type conversion before ‘=’ token
    line:60: error: array bound is not an integer constant
    line:60: error: expected constructor,destructor or type conversion before ‘=’ token
    line:61: error: expected constructor,destructor or type conversion before ‘=’ token
    line:62: error: expected unqualified-id before ‘for’ line:62: error: expected constructor,destructor or type conversion before ‘<' token line:62: error: expected constructor,destructor or type conversion before '++' token
    line:65: error: expected unqualified-id before 'return' line:66: error: expected declaration before '}' token

    Have you some idea what's wrong?

    Regards. bjduino@gmail.com

    • Fail copy in the script code, I fix that, check again with arduino ide 1.0.6
      this time I compile it and works without errors.

      Problem was in the line 50. Check that line.

      Regards

  2. Hello, I’ve the pcb dishwasher down and i’ve find your arduino perfect program. I’m waiting the item to repair.
    I need your help because I’ve a push button for program select and one button for delay start (3-6-9-12H). I’m newbie in arduino and C++ but after some days I tried some modifications.

    Can it Work ? Thank you very much !!!

    const int remiseAzero = 0;
    int lastkeybtnState = 0;
    int keybtnState = 0;
    int keybtnCounter = 0;
    int readKey(){
    keybtnState = digitalRead(keySelect); // lis en fonction du nombre d’appui sur le bouton
    if (keybtnState != lastkeybtnState) {
    if (keybtnState == HIGH) {
    keybtnCounter++;
    }
    lastkeybtnState = keybtnState;

    }
    if (keybtnCounter != 1) return btnRinse;
    if (keybtnCounter != 2) return btnEconom;
    if (keybtnCounter != 3) return btnNormal;
    if (keybtnCounter != 4) return btnStrong;
    if (keybtnCounter != 5) return btnFast;
    if (keybtnCounter != 6) { keybtnCounter = remiseAzero; lastkeybtnState = remiseAzero; keybtnState = remiseAzero; }
    }

    • you need a routine of when stop:

      if(keybtnCounter !=1) return btnRinse;
      if(keybtnCounter !=2) return btnEconom;

      if we only take these 2 lines, when you press one time the button automatically go to btnRinse routine all the time, you won´t be able to select another routine. you need a one loop I think, and with press start button go out to the loop and compare with
      if (keybtnCounter != 1) return btnRinse;
      if (keybtnCounter != 2) return btnEconom;
      if (keybtnCounter != 3) return btnNormal;
      if (keybtnCounter != 4) return btnStrong;
      if (keybtnCounter != 5) return btnFast;

      Check this http://www.arduino.cc/en/Tutorial/ButtonStateChange


Leave a Reply