/usr/share/fritzing/sketches/core/Fritzing Creator Kit DE+EN/creator-kit-en/Fritzing Creator Kit/Fortuneteller/Fortuneteller.ino is in fritzing-data 0.9.3b+dfsg-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /*
fortune teller
switching between five LEDs to tell the future
This example is part of the Fritzing Creator Kit: www.fritzing.org/creatorkit.
*/
int pins[] = {8,9,10,11,12}; // the pins of the LEDs are stored in an array
int tiltPin = 3; // pin number where the tilt switch is attached
void setup() {
for (int i=0; i<5; i=i+1){
pinMode(pins[i] , OUTPUT); // LED pins are declared as outputs
}
pinMode(tiltPin,INPUT); // pin of the tilt switch is declared as input
randomSeed(analogRead(0)); // initialize random number generator based on random state of pin zero
}
void loop() {
if (digitalRead(tiltPin)==HIGH){ // when the tilt switch is open
for (int i=0; i<5; i=i+1){ // all the LEDs
digitalWrite(pins[i],LOW); // get switched off
} //
int myRandom=random(0,5); // a random LED
digitalWrite(pins[myRandom],HIGH); // is switched on
delay(20); // the program is waiting to breath
}
}
|