[SOLVED] Button to Protocol

I’d like to be able to press a button on the android application and have it be read as either a number or character on the arduino nano. I wish to use this input to initiate a procedure pre-loaded into the arduino.

ideally, once a button is pressed, the app will pass a character to the arduino, this character will correspond to a function and the arduino will take over from there.

Basically I wish for the phone to act as a touchscreen interface for a desktop robot that will perform a function and then return to wait for another command from the phone.

The Nano is a poor choice for iOT systems due to memory size and lack of internet connectivity.

It would be much easier if you used an ESP from around $3 to $5.

Virtual pins can be linked to button widgets and as you press the button it calls each of your robotic functions.

1 Like

@foolzo Hello and Welcome to the Blynk Forum.

There are many resources here to help you learn how Blynk works, so that you can learn to control anything you want.

At the Upper Right of this page there are links to the Documents, Help Center and Sketch Builder, where you can learn the commands and see many example sketches that will help you get started.

You didn’t mention how you are going to connect the Nano to a Blynk Server, so guessing that you might be using an ESP setup as a Wireless modem, or the USB link, here is some links to get you started.

ESP WiFi - http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware
GET data from App to hardware - https://examples.blynk.cc/?board=Arduino%20Nano&shield=Serial1&example=GettingStarted%2FGetData

USB Serial link - http://help.blynk.cc/hardware-and-libraries/arduino/usb-serial
GET data from App to hardware - https://examples.blynk.cc/?board=Arduino%20Nano&shield=Serial%20or%20USB&example=GettingStarted%2FGetData

In a very simplistic explanation, the key is the use of a BLYNK_WRITE() function that will be called whenever a corresponding widget sends data or state change to the Hardware, you then incorporate your “do somthing” functions here:

// This function will be called every time Widget
// in Blynk app writes values to the Virtual Pin 1
BLYNK_WRITE(V1)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  // If pinValue equals whatever data you are looking for
     // Then do somthing here
}
1 Like

BTW, Blynk is way overkill if that is all you want it to do… Blynk is not a simple GUI for arduino, it is a full fledged interface and control setup for IOT. That is not to say that it can’t be used to simply control robots… do a search of this forum for the word robot and you will see.

Thanks, And it will be used to do more, I just need to understand if it can do this before committing time to it.

Easily… here is an OLD topic doing just that with a Nano and a little ESP for WiFi. Be aware… many changes have been make to Blynk libraries since so the sketch may not be a drop in solution, but it will show some basics… search for more recent ones as well.

But with this concept, can I have a single thing be entered, for example the press of a button, and then have the arduino automate the rest of a multi step function. Because in the video, each input is equivalent to one precise action, and not a set of actions.

I will explain the robot I wish to build.

This robot will pour mixed alcoholic drinks at a party.
The desired drink will be chosen from the phone screen.
For example, a rum and coke is chosen, using the rum and coke button in the application.
The arduino receives this and initiates the rum and coke function, which is comprised of turning stepper motors, reading sensors, activating air pumps and manipulating LEDs.

I wish for the press of a button to be equivalent to pressing a button directly attached to one of the digital pins on the arduino.

Sure, just as long as your independent function doesn’t run too long and/or block Blynk from it’s housekeeping and link to the server, otherwise it will disconnect and not see the next order. Basically good programming means good operating flow.

But your Nano seems a bad choice for a bartending robot… Blynk or no Blynk, perhaps too limited for that?

I missed this part… While this will work using the Apps direct pin control and having a constant polling loop looking at digital pin state, you might have better control using Virtual pins and coding your mixing functions in reaction to state changes detected by BLYNK_WRITE(vPIN) functions.