// Author: Nien Lam // Date: 09-15-2009 // Title: Finger Switches // Descr: Metal contacts attached to the fingers (index, middle, ring) when touched with // a metal plate will light the corresponding LED. When all 3 fingers close the // switch, the larger LED turns on. // Digital input pins for finger swtiches. int indexFinPin = 2; int middleFinPin = 3; int ringFinPin = 4; // Digital output pins for the LEDs. int firstLedPin = 8; int secondLedPin = 9; int thirdLedPin = 10; int masterLedPin = 11; void setup() { // Set finger switches as inputs. pinMode(indexFinPin, INPUT); pinMode(middleFinPin, INPUT); pinMode(ringFinPin, INPUT); // Set LEDs as output. pinMode(firstLedPin, OUTPUT); pinMode(secondLedPin, OUTPUT); pinMode(thirdLedPin, OUTPUT); pinMode(masterLedPin, OUTPUT); } void loop() { // Reset all LEDs to LOW state. digitalWrite(firstLedPin, LOW); digitalWrite(secondLedPin, LOW); digitalWrite(thirdLedPin, LOW); digitalWrite(masterLedPin, LOW); // Turn on LEDs depending on which finger switch is closed. if (digitalRead(indexFinPin)) digitalWrite(firstLedPin, HIGH); if (digitalRead(middleFinPin)) digitalWrite(secondLedPin, HIGH); if (digitalRead(ringFinPin)) digitalWrite(thirdLedPin, HIGH); // Turn on Master LED if all finger switches are closed. if (digitalRead(indexFinPin) && digitalRead(middleFinPin) && digitalRead(ringFinPin)) digitalWrite(masterLedPin, HIGH); // Add delay for each cycle. delay(200); }