Author Topic: Pulse output in receiver  (Read 261 times)

Wayne

  • RFduino Jr. Member
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Pulse output in receiver
« on: June 08, 2017, 07:36:34 AM »
Ok, I don't think it is possible, but, my knowledge is limited on this..
What I'm trying to do is using a device (footswitch button) in transmit to a receiver.
The receiver should only act once with a pulse of 350 ms and not to occur again during that current send of the footswitch, but if the button is released and pressed again, it should
pulse once more and not to do it again until a new send is sent.

I have tried doing toggles and all, but I get my pulse, but it repeats if I hold button closed.

I'm really do not want to do this on the send side, but if I need to, so be it..

So if anyone has a pointer, let me know please.
In the mean time, I will keep plugging at it..

Also, is their a simple debounce routine.. right now I'm just doing a woke option.. and HIGH tests on GPIO's
Working ok for testing.. 

Wayne

Wayne

  • RFduino Jr. Member
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: Pulse output in receiver
« Reply #1 on: June 22, 2017, 08:37:33 AM »
Success..

I'm sure I can do this on the footswitch (send) side, but I have it working on the receiver side at the moment.

Aaron helped me with the sample, then I was able to insert it with changes to accomplish the goal.
I'm not to sure about the timing, but it looks close to what I need.

The Objective is to receive the signal (button send from the footswitch) and enable a relay (led) for x seconds (200ms roughly).
Do this once and not to repeat until the next signal was received.
Make sure the pulse is equal to 200ms no matter what length of the trigger.

Here is the code in the loop area of the receiver for the foot switch.
Code: [Select]

if (modeRecvd == 0 && button == 50) //case 50:
  {
    // mode
    modeRecvd = 1;
    lastRecvd = millis();
    Serial.println("mode");
    digitalWrite(mode_led, HIGH);
    digitalWrite(save_led, LOW);
    digitalWrite(xray_led, LOW);
    digitalWrite(HLF_led, LOW);
    digitalWrite(security_led, LOW);
   
  } else {
    if (modeRecvd == 1 && millis() - lastRecvd >= 130)
    {
      digitalWrite(mode_led, LOW);
      lastRecvd = millis();
      Serial.println(button);
      if (button == 69)
      {
        modeRecvd = 0;
      }
    }

It also works as a send (foot switch)

I had a hard time trying different ways of doing this.