Go Down

Topic: Audomatic Garage Door Close (Read 3 times) previous topic - next topic

dxw00d

Quote
As I understand it a statement like (digitalRead(DoorShutSW) is basically shorthand (or another of writing) (DoorShutSW == HIGH)


Then you misunderstand, digitalRead() is function that returns the state of the pin. (DoorShutSW == HIGH) evaluates the pin number, not its state. I explained this in my earlier post.

http://arduino.cc/en/Reference/DigitalRead

rocketboy001

#11
Sep 27, 2012, 07:52 pm Last Edit: Sep 27, 2012, 07:54 pm by rocketboy001 Reason: 1

Quote
As I understand it a statement like (digitalRead(DoorShutSW) is basically shorthand (or another of writing) (DoorShutSW == HIGH)


Then you misunderstand, digitalRead() is function that returns the state of the pin. (DoorShutSW == HIGH) evaluates the pin number, not its state. I explained this in my earlier post.

http://arduino.cc/en/Reference/DigitalRead


Ok, good to know. You'll excuse my initial confusion (and perhaps overly overaggressive defense of what I was doing) as what I have does seem to work.

Looking back through where I read that (DoorShutSW == HIGH) was the same as (digitalRead(DoorShutSW) I realize that I misinterpreted what the person was saying. Again, confusion set in because I was being told that what I had would not work when it does, that's all.

I will adjust the code and retest when I get back in front of my Arduino... are there any suggestions as two how to deal with the beep every x number of minutes during the override? Also, any suggestions as to how to eliminate the goto would be welcome.

liudr

Whatever others pointed out, all being correct, is probably not helping you because you consider whatever "works" is correct already. You need to read a few sample programs that come with arduino. You can't just invent how to speak the C language. Read a few well written short samples and you might be able to mimic, until you truly understand. If you have some experience speaking a second language, you would agree with me. You can't just invent your own way to speak it. You mimic how native speakers talk until you can talk on your own. Those that pointed out your mistakes are the native speakers of the C language. Fighting them won't get your ideas understood by arduino. Read the sample code and hit the books.

rocketboy001


Whatever others pointed out, all being correct, is probably not helping you because you consider whatever "works" is correct already. You need to read a few sample programs that come with arduino. You can't just invent how to speak the C language. Read a few well written short samples and you might be able to mimic, until you truly understand. If you have some experience speaking a second language, you would agree with me. You can't just invent your own way to speak it. You mimic how native speakers talk until you can talk on your own. Those that pointed out your mistakes are the native speakers of the C language. Fighting them won't get your ideas understood by arduino. Read the sample code and hit the books.


I'm not fighting anyone. I'm genuinely looking for help. There was some confusion because people were pointing out errors - things that should not work - while I was seeing them as working. I was also misinformed on a particular aspect of how read the state of a pin. You can also understand my... dismay and frustration when I've spent the past couple of weeks writing this to come here and be told right off the bat that everything I've done is wrong.

With all that said:

1) I understand that I was reading the state of the pin wrong and will work in the suggested fix for that. Thank you.

2) I understand that that the use of the goto is frowned upon (though I did not know hoe vehement people were about it  :)). I used it 'cause it worked and as mentioned here (http://arduino.cc/en/Reference/Goto) I did not use in "unrestrained." I'm open to suggestions on how to eliminate this.

3) The original reason for my post: suggestions, ideas, on how to get a beep every x number of minutes while the override is active.

PeterH

#14
Sep 27, 2012, 08:28 pm Last Edit: Sep 27, 2012, 08:38 pm by PeterH Reason: 1

while(PIR1, PIR2 == HIGH);
All I can say is that this works.

...

I'm saying is that it does or at least seems to as far as I can tell. If it is in fact wrong then it is wrong in form and not functionality.


No, it doesn't work, for two reasons, both of which have been explained. But presumably your testing has not been sufficient to expose the bug yet. I suggest it would benefit you to be far less eager to dismiss people's criticisms of your code.

You asked about how to output a regular beep while the override was active. Personally, I suggest you get rid of the existing sequential blocking control structure and the fugly goto hack, and implement it as a state machine. Code this to execute asynchronously using the techniques shown in the 'blink without delay' example sketch and it would be easy to add in any other background processing you want in whichever state you want - such as blinking lights and making beeps. The design would be much simpler and clearer.
I only provide help via the forum - please do not contact me for private consultancy.

Go Up