Hi Everyone!
I'm new to the forum and am a total newb when it comes to "computer language". Though, I do have a fairly extensive knowledge in analog and digital electronics. The project I was working on was getting complicated so I decided, "Why not just use a microcontroller!" So, I recently purchased an Arduino Duemilanove with the ATMEGA 328 along with a proto shield and a serial LCD to design my project around.
After a couple hours of tinkering with example code and making LED's respond, Piezo's playing tones and LCD's displaying text; I found that MC's are somewhat easy and fun! Although I learned a lot in a couple hours, I still have A LOT to learn.
One aspect of this project I would like to figure out how to program is my so called "Coded Interlock Loop". What I'm looking to do is send a modulated signal (Say a 123Hz square wave for example) out one of the digital I/O pins that is looped to be received by another pin. From there, the signal is compared. If it matches, a high signal is output from a third I/O pin. If the signal is not seen on the second pin, the third pin goes low.
Seems like a fairly simple code to wright but I may be wrong. If someone could help me understand how to do this, that would be greatly appreciated!
Thanks!
Adam
Well my experiance is more with hardware then software, but perhaps I can plant the seeds of how your program could work.
Output a high on your first output pin, at the same time set a flag variable to a 1.
Read the input pin. Compare it to the flag variable. If equal then output a high to your second output pin, if not equal then set your second output pin low.
Now set your first output pin low and set the flag variable to zero.
Read the input pin and again do the compare and set the second output pin per the compare results.
Loop back to the start.
So it's not in C statement form. The compares are simple IF statemenets and the overall looping is done automatically by the Loop function.
Hey retrolefty!
Thanks for the reply, I think I get the picture of how that's done. Now I just have to figure out how to assemble it. Shouldn't be too hard though. I'll wright the code and post it here if I have any trouble.
Thanks Again!
Adam
By flag variable I meant to just define a variable that you will use as a flag in your program logic.
int MyFlag; // will define a variable that you can use as a flag.
By flag, I mean the variable will only contain two possible values, zero or one, depending on the state of the input pin when you read the input pin and then assign it's value to MyFlag. When using MyFlag in a IF statement, the statement is true if MyFlag contains a one (or any value other then zero) and the if statement will fail if MyFlag contains zero.