BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Using ASCII character codes with Virtual pin application

Before creating the topic

  1. Search forum for similar topics
  2. Check http://docs.blynk.cc and http://help.blynk.cc/
  3. Add details :
    • Hardware model + communication type. For example: Arduino UNO with Ethernet Shield
    • Smartphone OS (iOS or Android) + version
    • Blynk server or local server
    • Blynk Library version
    • Add your sketch code. :point_up:Code should be formatted as example below.

Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.

I have created a program which uses 4 virtual pins (all V1) to turn on different sequences of leds in a neopixel ring.
It works by using a seperate case
for each virtual pin pressed.
The problem is I would like to use characters (like A or B or X etc) to be the case trigge r.
However the Blynk widget for a button does not allow characters to be inserted because only the number pad is active.
Can somebody explain how to use the ASCII codes for characters in this situation.
``

What is the reason for using the characters for the case statement? Looks like you are just making it harder for yourself. You can set the vpin to any value you want. I don’t see the problem. Just enter the value of the char you want.

Thank you for replying.
I have another project which is very largeran has 26 case statements using characters.
These are intergral to other functions as well.
I have used another UI (Bluetooth Electronics) and all goes well.
But I like the Blynk programs UI better.
I have tried using the ASCII CODE NUMBERS but with no sucess

…BLYNK_WRITE(V1) {
int data =(param.asInt());
switch ( param.asInt()) {…

no success.
To rewrite the other program to change all the alphanumeric case references would take
Ages.
I tried using 65 for A as per table but it did not work.
Any suggestions?.?

That sounds like you have 4 widgets all attached to pin V1. Would you like to clarify exactly what this means?

It would be useful if you explained what type of widgets you are using in the app.

Have you tried using the text input widget? Obviously the C++ Switch/Case function only works with integer and character variable types, so if you use param.asString with the text input widget you’d need to convert the result to a char variable type for it to work.

BTW, when you post code to the forum it need to have triple backticks at the beginning and end, on a separate line. The characters you used appear to be decimal points rather than backticks.
Triple backticks look like this:
```
copy and paste them if necessary when posting code to the forum in future.

Pete.

Problem solved.

BLYNK_WRITE(V1){
int input =(param.asint());
char data = input;
switch (data) ```

Using this code an input of 65 will give the character A or 77 gives M
I am using the standard button set to V1 with the on setting for A is automatic and the off setting to M for manual.