Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть Arduino demo: State machine with push buttons and LEDs

  • Solstice
  • 2015-10-25
  • 2576
Arduino demo: State machine with push buttons and LEDs
Arduino (Brand)LEDpush buttonstate machineDemo!sgvDemo
  • ok logo

Скачать Arduino demo: State machine with push buttons and LEDs бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно Arduino demo: State machine with push buttons and LEDs или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку Arduino demo: State machine with push buttons and LEDs бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео Arduino demo: State machine with push buttons and LEDs

This is a short presentation of a demo where I implement a simple state machine using an Arduino, a push button and three LEDs.

The state machine goes to he next state whenever a push button is pressed. The trigger can be anything, such as a specific reading from a sensor and the state can perform any action desired.

To keep this demo simple I just used a push button to cycle through 3 LEDs where the first state turns them all off and each progressive state turns them on, one by one.

Sketch:

/*


Connect the positive side of your LED to Arduino digital pin 13
Connect the negative side of your LED to a 330 Ohm resistor
Connect the other side of the resistor to ground

*/


// First we'll set up constants for the pin numbers.
// This will make it easier to follow the code below.

const int button1Pin = 2; // pushbutton 1 pin
const int led1Pin = 13; // LED 1 pin
const int led2Pin = 12; // LED 2 pin
const int led3Pin = 11; // LED 3 pin

int iState;
bool bWasPressed; //Variable to see if the buton was pressed

void setup()
{
// Set up the pushbutton pins to be an input:
pinMode(button1Pin, INPUT);

// Set up the LED pin to be an output:
pinMode(led1Pin, OUTPUT);
pinMode(led2Pin, OUTPUT);
pinMode(led3Pin, OUTPUT);

//Default to state 0
iState = 0;
bWasPressed = false;

// initialize serial communication at 9600 bits per second:
// Serial.begin(9600);

}


void loop()
{
int iBtnState; // variable to hold the pushbutton state


// iBtnState: HIGH = button not pressed
// LOW = button is pushed


iBtnState = digitalRead(button1Pin);

//Now determine whether I need to change state.
if (iBtnState == 1)
{
//The button is not pressed. If the button was just
//released then go on ahead to the next state.
if (bWasPressed==1)
{
//Yes, the button was just released.
//Move to the next state.
iState++;

iState = iState % 4;

//Reset the button pressed flag.
bWasPressed = false;
}
}
else
{
//The button is pressed, just set the flag.
bWasPressed = true;
}

//Take action depending on the state of the machine.
switch (iState)
{
case 0:
//Turn off all LEDs
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, LOW);
digitalWrite(led3Pin, LOW);
break;
case 1:
//Turn on first LED
digitalWrite(led1Pin, HIGH);
break;
case 2:
//Turn on second LED
digitalWrite(led2Pin, HIGH);
break;
case 3:
//Turn on third LED
digitalWrite(led3Pin, HIGH);
break;
}

}

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]