Add Remote and LEDs to 2-Channel High-Power Relay Controller Shield

Thanks Travis,

I appreciate all your help on this. It seems like I am missing something super simple.

btw, I took KeyFob.cpp, and I add a bunch of logging, so I could see what is going on. ALL of the digitalRead calls return 0, no matter what button I push.

void KeyFob::evalFob()

{
recentFobID = Serial1.read();

char buffer[33];
int newStatus = 0;
int k1=digitalRead(kfb1);
int k2=digitalRead(kfb2);
int k3=digitalRead(kfb3);
int k4=digitalRead(kfb4);
int k5=digitalRead(kfb5);
int k6=digitalRead(kfb6);
int k7=digitalRead(kfb7);
int k8=digitalRead(kfb8);

char buttons[40];
itoa(k1, buffer, 10);
strcpy(buttons, "b1=");
strcat(buttons, buffer);

itoa(k2, buffer, 10);
strcat(buttons, ",b2=");
strcat(buttons, buffer);

itoa(k3, buffer, 10);
strcat(buttons, ",b3=");
strcat(buttons, buffer);

itoa(k4, buffer, 10);
strcat(buttons, ",b4=");
strcat(buttons, buffer);

itoa(k5, buffer, 10);
strcat(buttons, ",b5=");
strcat(buttons, buffer);

itoa(k6, buffer, 10);
strcat(buttons, ",b6=");
strcat(buttons, buffer);

itoa(k7, buffer, 10);
strcat(buttons, ",b7=");
strcat(buttons, buffer);

itoa(k8, buffer, 10);
strcat(buttons, ",b8=");
strcat(buttons, buffer);

Particle.publish("Buttons", buttons, 60, PUBLIC);

(I know it is ugly, but I’m not a C++ programmer, and this was the way I found to do it). BUT I see this in the events:

event: Buttons
data: {“data”:“b1=0,b2=0,b3=0,b4=0,b5=0,b6=0,b7=0,b8=0”,“ttl”:60,“published_at”:“2018-08-15T16:08:15.436Z”,“coreid”:“2e0028000447363333343435”}
event: Buttons
data: {“data”:“b1=0,b2=0,b3=0,b4=0,b5=0,b6=0,b7=0,b8=0”,“ttl”:60,“published_at”:“2018-08-15T16:08:18.997Z”,“coreid”:“2e0028000447363333343435”}
event: Buttons
data: {“data”:“b1=0,b2=0,b3=0,b4=0,b5=0,b6=0,b7=0,b8=0”,“ttl”:60,“published_at”:“2018-08-15T16:08:19.232Z”,“coreid”:“2e0028000447363333343435”}

Thanks,
Mark

I do have this plugged into the board correctly, right?

Hi Mark,

Yes, that appears to be correct. You should see an LED on the key fob overlay board light up when you press any button on the key fob remote.

I’ll have a look at the code later on.

Thank you Mark,
Travis Elliott

Hi Mark,

Try this version of the code. I had to disable the LEDs connected to A3 and A4 as they conflicted with the key fob remote. See if this at least works to indicate which button was pressed and if the relays work as expected.

https://go.particle.io/shared_apps/5b7af085f3ac090c530005d5

I had figured out that the A3 and A4 were causing problems as well, and removed them. I did try your code, and it still always says Button 1 Pressed. Never any other button, never a button release either.

Hi Mark,

I tested that code here with a 4 button remote and I was getting Button press events for all 4 buttons. There is no release event because the code is not monitoring for that. Are you sure you loaded the code I sent over? It’s definitely working here.