The VT pin isn't of to much concern for me right now so it just tucks in between the two pin banks :) |
Check out the code below. This is great but if I don't want to constantly poll for buttons I may miss one. So my intention is to order a latching version, when you press the button on the keypad the pin goes high and stays high until you press it again. My thought is that if I am powering the receiver from the arduino then I can read it maybe once a second or even less often then when a high state is detected then I can simple "reboot" the receiver by dropping the +5v pin to ground. So until I get one in I will hope it resets back to ground on all the signal pins like I need
/*-------------------------------------------------------- Adafruit's Simple RF Receiver example http://www.adafruit.com/products/1096 Author: Chris Crumpacker Date: August 2013 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. Sketch Notes: This is set as if you put the reciever directly onto an arduino with gnd in pin 2 and the VT pin in the gap between the pin banks. --------------------------------------------------------*/ #define GROUNDPIN 2 #define POWERPIN 3 // Arduino Pin Numbers int signalPin[4] = { 4, 5, 6, 7 }; // Reciever Pin Names const char* pinName[] = { "D3", "D2", "D1", "D0" }; // Keyfob Pin Names const char* buttonName[] = { "D", "C", "B", "A" }; int lastSignalState[] = { 0, 0, 0, 0 }; int signalState = 0; float onTime = 0.00; void setup() { // Set the ground pin to a Low output pinMode(GROUNDPIN, OUTPUT); digitalWrite(GROUNDPIN, LOW); // Set the +5v pin to a High output pinMode(POWERPIN,OUTPUT); digitalWrite(POWERPIN, HIGH); // Setting the signal pins as inputs for (int i = 0; i < 4; i++) { pinMode(signalPin[i], INPUT); } // Starting the serial interface Serial.begin(19200); } void loop(){ // For each of the 4 pins we loop thru and check the state. for (int i = 0; i < 4; i++) { // Read the current pin signalState = digitalRead(signalPin[i]); if (signalState != lastSignalState[i]) { // if the state has changed... if (signalState == HIGH) { // ...and the current state is HIGH... Serial.print("Receiver Pin: "); Serial.println(pinName[i]); Serial.print("Keyfob Button: "); Serial.println(buttonName[i]); Serial.println("Switched ON"); Serial.println("------------------------------"); onTime = millis(); } else { // ...and the current State is LOW... Serial.print("Receiver Pin: "); Serial.println(pinName[i]); Serial.print("Keyfob Button: "); Serial.println(buttonName[i]); Serial.print("Switched OFF after "); Serial.print(((millis() - onTime) / 1000.00)); Serial.println(" seconds"); Serial.println("------------------------------"); } } // save the current state to the last state array lastSignalState[i] = signalState; } }
Thank you so much this great short and easy tutorial was so helpful i was able to use my receiver!
ReplyDeleteGlad it was helpful.
Delete
ReplyDeleteAttractive section of content. I simply stumbled upon your blog and in accession capital to assert that I acquire in fact enjoyed
account your blog posts. Anyway I’ll be subscribing
on your augment or even I success you access constantly quickly.
Here's my website : -- 부산달리기
(jk)
Spot on with this write-up, I truly believe that this website needs a lot more attention. I'll probably be back again to read more, thanks for the advice!
ReplyDeletePlease Visit My homepage ➤ 야동
I have always disliked the idea because of the costs 오피 . Is usually able to answer customer questions.
ReplyDelete"What i do not realize is actually how you're no longer actually much more
ReplyDeletesmartly-liked than you might be now. You are very intelligent.
You know thus considerably when it comes
to this matter, produced me in my view believe it from numerous numerous angles.
Its like men and women don't seem to be fascinated until it's something to do with Girl gaga!
Your individual stuffs outstanding. All the time care for it up!"
my web page ➥ 마사지
I haven't checked in here for some time since I thought it was getting boring, but the last several posts are good quality so I guess I'll add you back to my everyday blog list. You deserve it my friend �� 건전마사지
ReplyDeleteHello there, You’ve done an incredible job. I will definitely digg it and personally recommend to my friends. I’m confident they’ll be benefited from this website.| 스포츠토토티비
ReplyDelete바카라사이트 Hi there, You have done a great job. I will definitely digg it and
ReplyDeletepersonally recommend to my friends. I am confident they will be benefited from this web site.
바카라사이트 This article presents clear idea for the new people of blogging, that really how to do running a
ReplyDeleteblog.
Very efficiently written information. It will be valuable to everyone who utilizes it, as well as yours truly. Keep doing what you are doing – for sure i will check out more posts.
ReplyDelete토토
경마
온라인경마
I will recommend your website to everyone. You have a very good gloss. Write more high-quality articles. 스포츠토토
ReplyDeleteGreat article I enjoy reading your thoughts. More power to your website. Please visit mine too 온라인카지노
ReplyDeleteIt's amazing that you have that kind of idea writing this article. Thank you for valuable article. 바카라사이트
ReplyDeleteThis is really interesting, You’re a very skilled blogger. 카지노사이트존
ReplyDeleteThis piece of writing is truly a fastidious one it assists new web users, who are wishing in favor of blogging.
ReplyDeletehttps://www.safecasinosite.net
I really enjoy your web’s topic. Very creative and friendly for users. Definitely bookmark this and follow it everyday. 바카라사이트
ReplyDelete