12 Mart 2016 Cumartesi

Arduino Buton ile Led Yakma ( Controlling led using pushbuttons Arduino )

DEVRE ŞEMASI



KODLAR



// Pin numaralarını belirle
const int buttonPin = 2;     // buton pin numarası
const int ledPin =  13;      // Led pin numarası

// variables will change:
int buttonState = 0;         

void setup() {
  //  Led'i çıkış olarak ayarla
  pinMode(ledPin, OUTPUT);
  // buton giriş olarak ayarla
  pinMode(buttonPin, INPUT);
}

void loop() {

  buttonState = digitalRead(buttonPin);


  if (buttonState == HIGH) 

{
   
    digitalWrite(ledPin, HIGH);
  } else {
    
    digitalWrite(ledPin, LOW);
  }
}

Hiç yorum yok:

Yorum Gönder