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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| int ledPin = 11;
int ledPin1 = 2;
int ledPin2 = 3;
int ledPin3 = 5;
int ledPin4 = 20;
int ledPin5 = 6;
int ledPin6 = 7;
int ledPin7 = 8;
int ledPin8 = 9;
const uint8_t touchPin = 0;
const uint8_t touchPin1 = 1;
const uint8_t touchPin2 = 15;
const uint8_t touchPin3 = 16;
const uint8_t touchPin4 = 4;
const uint8_t touchPin5 = 18;
const uint8_t touchPin6 = 19;
const uint8_t touchPin7 = 22;
const uint8_t touchPin8 = 23;
int touchVal;
const int threshold = 840;
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(ledPin6, OUTPUT);
pinMode(ledPin7, OUTPUT);
pinMode(ledPin8, OUTPUT);
}
void loop() {
{ touchVal = touchRead(touchPin);
Serial.print(touchVal);
digitalWrite(ledPin, touchVal > threshold);
}
{ touchVal = touchRead(touchPin1);
Serial.print(touchVal);
digitalWrite(ledPin1, touchVal > threshold);
}
{ touchVal = touchRead(touchPin2);
Serial.print(touchVal);
digitalWrite(ledPin2, touchVal > threshold);
}
{ touchVal = touchRead(touchPin3);
Serial.print(touchVal);
digitalWrite(ledPin3, touchVal > threshold);
}
{ touchVal = touchRead(touchPin4);
Serial.print(touchVal);
digitalWrite(ledPin4, touchVal > threshold);
}
{ touchVal = touchRead(touchPin5);
Serial.print(touchVal);
digitalWrite(ledPin5, touchVal > threshold);
}
{ touchVal = touchRead(touchPin6);
Serial.print(touchVal);
digitalWrite(ledPin6, touchVal > threshold);
}
{ touchVal = touchRead(touchPin7);
Serial.print(touchVal);
digitalWrite(ledPin7, touchVal > threshold);
}
{ touchVal = touchRead(touchPin8);
delay(750);
Serial.print(touchVal);
digitalWrite(ledPin8, touchVal > threshold);
}
} |
Partager