2.1kviews
Arduino ile yeni tanışanlar için kolay ve anlaşılır bir devredir. Anahtar ile ledimizi açıp kapatacağız. Bu devre için gerekli olan malzemeler anahtar açıp kapama için, 1 adet led, arduino ve bir kaç tane kablo. Arduinomuzu aşağıdaki bağlantı şeklinde olduğu gibi kuralım.

int Led = 2; //LED is attached to pin 2
int button = 13; //button is attached to pin 13
void setup() {
// put your setup code here, to run once:
pinMode(Led, OUTPUT); //LED is declared as output device
pinMode(button, INPUT); //nutton is declared as input device
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(button == HIGH)) //Here we are checking if the button is pushed
{
digitalWrite(Led, HIGH); //Here we are turning LED on
}
else //Here we are checking if the button is not pushed
{
digitalWrite(Led, LOW); //Here we are turning LED off
}
}
Arduinomuzu bilgisayara bağlayarak port seçimini yapıp arduinomuzu bilgisayara tanıttıktan sonra yukarıda verdiğim kodları arduino kodlarımızı yüklüyoruz.






Son yorumlar