2 way lighting circuit control with blynk and feedback updates

Yup the idea would be put a trivial task on the short press of the button so that it can be actioned too.

Any ideas around this and I’d love to hear them! :smiley:

My use case was, short press stop/start a timer, and long press was reset the timer to 0. So it wasn’t an issue.

well, intuitively it should take one action:
if button is short pressed do this
if button is long pressed do that
this is how it works on every phone or device.

i would measure the time between if(param.asInt(), and if(!param.asInt()
and:

if the measured time is lower than xxxx millis, it is a short click:
invoke void shortClick()

if millis longer than xxxx millis, invoke void longClick()

2 Likes

Updated the code… great idea! I think it will work! :smiley:

The action for the short press happens on the FALLING side which is the only issue really.

i see 2 problems:

  • int pressTime should be unsigned long
  • the else case will continuously be executed after releasing the button, while millis() - pressTime) < 999
1 Like

yes, but this is how things work. otherwise it can not decide if it is a long press or short, it has to wait to see :slight_smile: check on your phone keyboard. until you not release a button, it will not write a letter.

I have to head to work but please update the code with changes to the issues you listed. I think snippets of code like this will be very benefitial to new Blynkers trying to work out SimpleTimer :slight_smile:

If you want to help keep this thread clean, PM me the code and ill update my post :slight_smile:

yes but when it is latching in that state surely it is irrelevant ???

Cheers

kev

as i said in my earlier post, i do not think so. but you can try and see, that is the best you can do.

I have tried it @Wanek and it works brilliantly!!! I guess its because as the switch makes it remains in that state until you toggle it the other way

Cheers Kev

probably. i never used these kind of switches so far, so i do not have any experience on these. but glad it works :wink:

Yeah sure does very well and probs because of this explanation in your attachment. If the switch is moving from one state to another and staying there it becomes irrelevant as he describes here …

because of this if I can manage to use my existing two way wiring at the wall switch, back to the arduino, I will re-wire it all to use 5v logic the switch then just hard toggles the data pin to either logic 1 or 0 and the blynk app does the same.

So I guess a latching switch is the solution unless you need to use a momentary one for other functions ie long hold etc

Cheers

kev

true.
the inconvenience i see with this, is that unlike buttons, switches can stay in 2 positions, and you never know when it is “on” or “off” the light. this can be surprise for a person who is not get used with the system :slight_smile:

but wouldnt you know as the light would be lit up !!! and also the blynk app would tell you ?

HI sir

your program interesting but i am making for 4 channel can you modify sketch for 2 channel so very easily i hope you understand my problem

thanks sir

very easy indeed which is why my vrbls have a 1 after them just duplicate everything ie RELAY2_PIN AC_Sens2_pin etc etc but within the same void loops ie AC_detect etc

hope that makes sense - I am using 9 channels when I implement this

Cheers

Kev

@Khatrichaitanya As I have already asked twice, I moved your 4 channel code into your own post and removed your posting in the two other topics you had interjected into.

Please use your own topic to request any assistances. Thank you.

@Gunner thanks for separating this out bud makes a lot more sense to me now as well!!!

Cheers

Kev

A post was split to a new topic: Looking for assistance with single Vpin control of multiple lights

Hi sir, may i ask a diagram on how you wire them all especially on the relay, 2way switch and the isolation.

Thank you in advance.

hi i just want to just this will be the isolation testing board right?