/*Copyright (C) 2011 by Regis GrisonPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.*//* TODO : - verifier les sorties a utiliser - ajouter des vraies fonctions a la place des TODO - tester le circuit - allumer le "jackpot" de facon non bloquante*/// lightsint light1Pin = 2;int light2Pin = 3;// coilsint coil1Pin = 4;int coil2Pin = 5;int coil3Pin = 6;// switchesint switch1Pin = 7;int switch2Pin = 8;int switch3Pin = 9;int tiltPin = 10;// vars to read switch statesint switch1 = 0;int switch2 = 0;int switch3 = 0;int tilt = 0;// counterint count = 0;// function that should play a sound (must be able to play more than once)void playSound(int track, int repeat=1){ // TODO}// function that will show a value on the displayint increaseAndDisplayValue(int value){ value++; // TODO: show on display return value;}void setup(){ // init pins pinMode(light1Pin, OUTPUT); pinMode(light2Pin, OUTPUT); pinMode(coil1Pin, OUTPUT); pinMode(coil2Pin, OUTPUT); pinMode(coil3Pin, OUTPUT); pinMode(switch1Pin, INPUT); pinMode(switch2Pin, INPUT); pinMode(switch3Pin, INPUT); pinMode(tiltPin, INPUT); // play a sound playSound(1); // lights on... digitalWrite(light1Pin, HIGH); digitalWrite(light2Pin, HIGH); // ...for 5 seconds... delay(5000); // ...and off digitalWrite(light1Pin, LOW); digitalWrite(light2Pin, LOW); }void loop(){ // read data switch1 = digitalRead(switch1Pin); switch2 = digitalRead(switch2Pin); switch3 = digitalRead(switch3Pin); tilt = digitalRead(tiltPin); // 2 switches at the same time will play a sound twice if ((switch1 && switch2) || (switch1 && switch3) || (switch2 && switch3)) playSound(2, 2); // any switch will play a sound else if (switch1 || switch2 || switch3) playSound(2); // every switch must increase the counter if (switch1) count = increaseAndDisplayValue(count); if (switch2) count = increaseAndDisplayValue(count); if (switch3) count = increaseAndDisplayValue(count); // special jackpot for 100 switches if (count >= 100) { // show we are happy... playSound(3); digitalWrite(coil1Pin, HIGH); digitalWrite(light1Pin, HIGH); // ... for 5 seconds... delay(5000); // ...and no more digitalWrite(coil1Pin, LOW); digitalWrite(light1Pin, LOW); }}