int inPin = 2; // bilgi girdisi alacağım sensörün sinyal bacağını 2 ye bağladık. int outPin = 13; // output olarak led pinini 13 e bağladık. int LEDstate = HIGH; // ledin başlangıç durumu int reading; // giriş bilgisi okuma int previous = LOW; // giriş bilgisinden önceki okuma long time = 0; // çıkış pininin en son değiştirildiği zaman long debounce = 50; // titrerse, çıkış süresi artar void setup() { pinMode(inPin, INPUT);// sensör bilgisi input olarak ayarlandı digitalWrite(inPin, HIGH); // turn on the built in pull-up resistor pinMode(outPin, OUTPUT); Serial.begin(9600); } void loop() { int switchstate; reading = digitalRead(inPin); Serial.println(reading); // If the switch changed, due to bounce or pressing... if (reading != previous) { // reset the debouncing timer time = millis(); } if ((millis() - time) > debounce) { // whatever the switch is at, its been there for a long time // so lets settle on it! switchstate = reading; // Now invert the output on the pin13 LED if (switchstate == HIGH) LEDstate = LOW; else LEDstate = HIGH; } digitalWrite(outPin, LEDstate); // Save the last reading so we keep a running tally previous = reading; }