// constants won't change. They're used here to set pin numbers:
const int BUTTON_PIN = 7; // the number of the pushbutton pin
// Variables will change:
int lastState = HIGH; // the previous state from the input pin
int currentState; // the current reading from the input pin
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// initialize the pushbutton pin as an pull-up input
// the pull-up input pin will be HIGH when the switch is open and LOW when the switch is closed.
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
// read the state of the switch/button:
currentState = digitalRead(BUTTON_PIN);
if(lastState == LOW && currentState == HIGH)
Serial.println("The state changed from LOW to HIGH");
// save the last state
lastState = currentState;
}
الكود الثاني
// constants won't change. They're used here to set pin numbers:
const int BUTTON_PIN = 7; // the number of the pushbutton pin
const int LED_PIN = 3; // 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(LED_PIN, OUTPUT);
// initialize the pushbutton pin as an pull-up input:
// the pull-up input pin will be HIGH when the switch is open and LOW when the switch is closed.
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(BUTTON_PIN);
// control LED according to the state of button
if(buttonState == LOW) // If button is pressing
digitalWrite(LED_PIN, HIGH); // turn on LED
else // otherwise, button is not pressing
digitalWrite(LED_PIN, LOW); // turn off LED
}
Поделиться в:
Доступные форматы для скачивания:
Скачать видео mp4
Информация по загрузке:
Скачать аудио mp3
Похожие видео
array(10) {
[0]=>
object(stdClass)#4206 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "tJPql1BlG5o"
["related_video_title"]=>
string(80) "الأردوينو للمبتدئين 4: تشغيل buzzer بإستخدام زر"
["posted_time"]=>
string(25) "3 месяца назад"
["channelName"]=>
string(24) "أحمد تك Ahmed tech"
}
[1]=>
object(stdClass)#4179 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "ltdKNS0FU_o"
["related_video_title"]=>
string(169) "#2 Светодиод, расчет резистора, конденсатор - самый понятный курс по электронике для новичков"
["posted_time"]=>
string(21) "3 года назад"
["channelName"]=>
string(21) "Виктор Осин"
}
[2]=>
object(stdClass)#4204 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "-mrrOkeKHXM"
["related_video_title"]=>
string(48) "Brief revolution of computer: AI generated video"
["posted_time"]=>
string(19) "1 час назад"
["channelName"]=>
string(13) "Aikinyi Media"
}
[3]=>
object(stdClass)#4211 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "kCey8Srxx7c"
["related_video_title"]=>
string(93) "Новейшая ракета РФ уничтожена / Жаркая ночь в Крыму"
["posted_time"]=>
string(24) "10 часов назад"
["channelName"]=>
string(10) "NEXTA Live"
}
[4]=>
object(stdClass)#4190 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "AQVocGeQPAQ"
["related_video_title"]=>
string(97) "الأردوينو للمبتدئين 6 : تشغيل led باستخدام مقاومة ضوئية"
["posted_time"]=>
string(25) "3 месяца назад"
["channelName"]=>
string(24) "أحمد تك Ahmed tech"
}
[5]=>
object(stdClass)#4208 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "xyrWTinAPXg"
["related_video_title"]=>
string(160) "Топ-экономист Липсиц: Россия банкрот! У Путина больше нет денег! Вот что нас ждет теперь!"
["posted_time"]=>
string(23) "5 часов назад"
["channelName"]=>
string(33) "В гостях у Гордона"
}
[6]=>
object(stdClass)#4203 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "aQRj2Z-Eb1Y"
["related_video_title"]=>
string(129) "⚡️ Самая масштабная атака РФ по Украине || Путина просят о помиловании"
["posted_time"]=>
string(24) "11 часов назад"
["channelName"]=>
string(23) "Время Прядко"
}
[7]=>
object(stdClass)#4213 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "taKtPAK7pmM"
["related_video_title"]=>
string(51) "أردوينو للمبتدئين8 : تشغيل RGB"
["posted_time"]=>
string(25) "3 месяца назад"
["channelName"]=>
string(24) "أحمد تك Ahmed tech"
}
[8]=>
object(stdClass)#4189 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "YyGtvHde084"
["related_video_title"]=>
string(104) "أردوينو للمبتدئين 12 : تشغيل حساس منسوب المياه الجزء الأول"
["posted_time"]=>
string(25) "2 месяца назад"
["channelName"]=>
string(24) "أحمد تك Ahmed tech"
}
[9]=>
object(stdClass)#4207 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "omPfclxinq0"
["related_video_title"]=>
string(160) "Это отличная идея😱!! Откройте для себя новую функцию трансформера, который поразил мир"
["posted_time"]=>
string(21) "7 дней назад"
["channelName"]=>
string(13) "King Homemade"
}
}