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

How to add lables when my mega2560 digitalread is HIGH

hardware

#21

i cannot understand the Second option…

my project need automatically setproperty in menu widget after connecting the power supply to atmega and nodeMcu.

but after this I want to control Actuators from atmega.

so basically i want to read and write to atmega command and controlling it through Blynk app.


#22

both are same in my IDE :grin:


#23

As your code it is not working in my app because it takes
as i wrote code like this

BLYNK_WRITE(V5) {
  if (param.asInt == 1) { // assumes a 1 or HIGH to continue
  Blynk.setProperty(V5, "labels", "MENU1", "MENU2", "MENU3");
  }
}

so when i choose Item0 in my app which is Index 1 for Blynk

it then shows menu 1 2 3

not like when i give digital input and then it has to show menu


#24

But all you are doing is sending a 1 to the ESP upon MEGA button press… so why wouldn’t it work (aside from all the button bounce potential, etc… but that is a whole other issue)

Besides a bool can only respond with a 0 or 1 (true or false) so not any different then the basic if(param.asInt)


#25

also

if(param.asInt)

give me error like

cannot convert ‘BlynkParam::asInt’ from type ‘int (BlynkParam::)()const’ to type ‘bool’


#26

Sorry… typing from memory… I probably made a syntax error… hold the line please… :musical_score:


#27

Yep :blush:

 if (param.asInt()) { 

#28

So how can i change the menu function?
I have to complete it today so i can create more from this.


#29

yes sir now no error :grinning:


#30

still without giving 5v to my digital pin 52 it take signal 1 and change the menu widget property


#31

Well… to be honest, I haven’t been following all of your topic, so I am unsure exactly what you are doing. But at a glance…

If you have a list of choices you want to pick from on the ESP, but you want them to be chosen from the Mega… then first you have to have a good way to do multiple choice from the Mega… a single button can only do one proper choice when pressed.

But if you can send, for example a number between 1 and 3, then the receiver can use switch case to respond acordingly.

https://www.arduino.cc/reference/en/language/structure/control-structure/switchcase/

BLYNK_WRITE(vPin) {
switch (param.asInt()) {
    case 1: { // Item 1
        // Do something for choice 1
        break;
      }
    case 2: { // Item 2
        // Do something for choice 2
        break;
      }
    case 3: { // Item 3
        // Do something for choice 3
        break;
      }
  }
}

#32

ya thanks @Gunner

my topic is only send digital signal from atmega to Nodemcu which will change the Menu widget property and also in the future i can

Do reverse like send signal from the Blynk and it can turn On/Off in Atmega 2560.

only this simple thing but problem is Menu widget is not changes its labels when i press Run button. I have to choose the menu widget {[item0] , [Item1]}

when item0 is choose it will change to Menu 1 , menu 2 , menu 3

but i don’t won’t this working like, as i mentioned above my procedure.

Well… I’m trying your switch case procedure than get back to you on this.


#33

@Gunner

still repeating this problem not giving 5v to digital input and give me my labels.

what to do in atmega ? because i haven’t give any digital input.


#34

Sorry, I am not following exactly what you are trying to do with the Mega’s digital input in a way that it can change the ESPs menu option.

I thought you were using the Mega becasue it had lots of I/O (presumably for output control of lighting) and using Easy therasnfer to do so.

Now you are using Blynk on both and using Blynk’s bridge… but if you are using Blynk on the Mega… then what do you need the NodeMCU for? Just add in an ESP-01 (in AT mode as a WiFi to serial transceiver) to the Mega and use it by itself with Blynk.


#35

Sorry sir @Gunner I understand you are busy.
but i already Purchased the Nodemcu and i have not Esp-01 that why i’m using nodemcu as an wifi module

also nodemcu will beneficial for me if i need more I/o in future it will use in my project.


#36

Well, then you cannot use Blynk (and thus Blynk’s bridge) for the Mega as it cannot connect to the server and I don’t think you can even get a NodeMCU to act as a AT mode Serial to WiFi transceiver… so it is back to using Easy Transfer for you.


#37

ya Before your reply i’m trying Easy transfer

just developing the code if any problem happens will send you a code.


#38

Well I am heading to :sleeping::sleeping::sleeping: so until next time…


#39

Okk Thanks for Your help @Gunner

and Wish you a Happy New Year advance.


#40

If all you’re trying to do is detect with your Arduino if a pin on the NodeMCU is high, then why not just connect the NodeMCU pin dircctly to your Arduino and monitor the logic level of the pin that it’s connected to?
The NodeMCU will give 3.3v outut to the pin whne it’s HIGH, which will almost certainly b treated as a HIGH signal by the Arduino.

If you want to do the opposite, then you’ll need a resistor to drop the voltage from 5v to 3.3

In either case, the GND pins of both devices will need to be shared.

Pete.