Blynk Board Project Guide

Pages
Contributors: jimblom
Favorited Favorite 18

Project 2: Physical Button, Blynk LED

In the previous experiment, we used the button widget to receive a digital input and produce a digital output -- pressing a button on the app toggled an LED on the board. Now let's do the opposite -- use a button on the Blynk Board to toggle an "LED" in the app.

Blinking LED Widget

This project introduces the LED widget -- a simple tool for indicating the digital status of a Blynk Board input.

Blynk Setup

There should still be plenty of room in the Blynk Board project for the LED widget. You can either keep the button widget from the previous project, or remove it to save a little space. If it's not bugging you, we suggest keeping the button widget around -- you'll be re-configuring and using it again soon.

Saving and Re-Purposing Widgets

Widgets cost Blynk energy! Even if you get most of that energy refunded when you remove it from a project, it can take a psychological toll – every energy point is precious!

Throughout this guide, never feel obligated to remove any widget from a project – even if you're not using it in the active project. That's especially true with the button and value widgets, which will be reocurring throughout this project guide.

Add an LED Widget to V1

Like the button widget before, follow these steps to add an LED widget:

  1. If your project is running touch the sqaure button in the upper-right corner to stop it.
  2. Touch anywhere in the blank project space to open the widget box.
  3. Select the LED widget near the top of the "Displays" section.

Adding an LED from the Widget box

  1. Drag and position the LED widget anywhere in your project space.
  2. Touch the LED widget to open up the Settings dialog, and adjust these values:
    1. Name: "Btn" (not "Button" for reasons...)
    2. Pin: V1. Any pin beginning with a "V" will be found under the "Virtual" list.
    3. Color: Touch the red circle to change the color of your LED. You can even set it up as a mythical black LED.

Configuring the LED settings

Touch the Play button in the upper-right corner to start the project back up.

Blynk Run

With your project running, push down on the little gold circle of the Blynk Board's push-button.

Pressing the button on the Blynk Board

While you're holding the button down, you should see the Blynk project's LED illuminate. Depending on lagtime, the LED may take a couple seconds to notice the button is pressed. Releasing the button will turn the LED back off.

Virtual Pins

V1, which we're using in this example to control the Blynk LED state, is one of the Blynk project's 32 virtual pins – a custom-programmed input or output, that can read or write values of all types to the Blynk Board or app.

Instead of directly reading or writing to digital or analog pins, virtual pins have to be implemented in firmware (the code running on the board). When you start writing your own Blynk programs, you can re-define these virtual pins to read or write any value, or to control anything that meets your fancy. For now, though, these pins are all defined in the Blynk Board's firmware; you should discover nearly all 32 of them throughout this guide.

Going Further: Launch a Rocket

Blynk LED widgets are great for indicating the digital status of any input pin, or any other virtual pin. You can tie just about any digital input into the 0 pin on the Blynk Board.

For example, grab a couple alligator clips and a rocket-launcher-style toggle switch, then connect them up like this:

Connecting clips to the rocket launcher switch

Be careful not to allow the two alligator clips to touch -- it's a tight fit, but it works!

Then connect the black wire to GND and the colored cable to 0.

Now, turning on the LED is even more satisfying! When the toggle switch is set to "ON", the LED should illuminate.