3 لایک
-
2
Post By ARMARMARS@YAHOO.COM
-
1
Post By magmagmary
-
سلام پرروژه شما بسیار ساده است، به طور کلی شما باید دو تا از پین های آردوینو را استفاده کنید، یکی از آنها به عنوان ورودی تعریف کنید و دیگری را به عنوان خروجی.
بین ورودی را برای سنسور PIR یا همون حرکتی استفاده خواهیم کرد.
پین خروجی را برای رله.
اینم کد:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
مجوز های ارسال و ویرایش
- شما نمیتوانید موضوع جدیدی ارسال کنید
- شما امکان ارسال پاسخ را ندارید
- شما نمیتوانید فایل پیوست کنید.
- شما نمیتوانید پست های خود را ویرایش کنید
-
مشاهده قوانین انجمن
SEO by vBSEO