Show Posts
Pages: 1 ... 35 36 [37] 38 39 ... 294
541  Using Arduino / Programming Questions / [SORTED thanks] Nested "if" with an "else" on the outer "if" on: July 12, 2014, 04:12:52 am
Hi all,

Maybe I'm just having a mental block here, but I can't see how to make an "else" belong to the outer "if" of a nested "if"...

Code:
if (outer test)
{
    if (inner test)
       {
                //stuff
        }

else   // I want this to be alternate to "outer test" not "inner test"
      {
         //stuff
      }
}

Am I missing a trick here guys?

EDIT.... I'm thinking I should put both tests in the first (and thus only) if with &&

Code:
if (outer test && inner test)
       {
                //stuff
        }

else
      {
         //stuff
      }
542  Using Arduino / Project Guidance / Re: Share an IR Reciever between 2 devices? on: July 12, 2014, 03:21:09 am
I think the RPi works on 3.3v rather than the Arduino's 5v. There would be a problem if the IR device lets 5v get to the RPi.

...R

Except he said the IR is getting its 5V from the RPi in the first place.....
543  Using Arduino / Programming Questions / Re: Alternative to using delay any help appreciated. on: July 12, 2014, 02:06:12 am
These should help....

http://arduino.cc/en/Tutorial/BlinkWithoutDelay

https://www.youtube.com/watch?v=3VZgaJBrZD8
544  Using Arduino / Project Guidance / Re: Share an IR Reciever between 2 devices? on: July 12, 2014, 12:46:23 am
Ahh so the ground acts as electrical ground AND a reference point for the signal?

So I would only need the 5v pin of the IR Receiver connected to one of them, but ground and signal would need to be connected to both of them.

Think of how you would measure the signal with a meter. You can't just jab the red lead onto the signal output: you have to jab the black one in on the 0 too  smiley-cool

But heed what drksam said too: the signal's voltage will be made available to both devices but I'm not 100% sure if there would be any significant current required from the sensor which I guess could fall short on that.... YMMV.
545  Topics / Robotics / Re: Why would it not accept DC jack as power supply on: July 12, 2014, 12:11:35 am
Quote
it perfectly powers the arduino but does not run the code

If it powered the Arduino perfectly it would run the code, so it's not perfect.

Quote
i dont think description of the assembly of the bot has to do anything with it as it powers up when connected through USB

You're trying to out-think anything that anyone might suggest. You should indeed provide connection details.

Have you powered the motors separately or is it all powered from the Arduino? If so, that's asking for trouble.
546  Community / Bar Sport / testing.... ignore on: July 12, 2014, 12:03:58 am
just testing attaching code: never tried that before
547  Using Arduino / Project Guidance / Re: Share an IR Reciever between 2 devices? on: July 11, 2014, 11:21:22 pm
You would need to have the grounds connected, else the signal voltage at the Arduino will have no meaning, a bit like one hand clapping.
548  Using Arduino / Project Guidance / Re: Password checker on: July 11, 2014, 10:38:17 pm
already solved

You should re-establish your first post. As it stands now, this thread is useless to anyone who might want to learn from your question and the members' answers, since your question has disappeared.
549  Topics / Robotics / Re: Servo comunication problem on: July 11, 2014, 10:21:18 pm
It's so much easier to read code if you use the # tag just above the  smiley-wink smiley-sweat smilies.

Without the code tags, some of the code gets interpreted as formatting so you get this:

  Serial.begin(9600);
  motor.attach(smiley-cool;
}

..... not this:

Code:
  Serial.begin(9600);
  motor.attach(8);
}
550  Using Arduino / Programming Questions / Re: State machine modeling on: July 10, 2014, 11:30:27 pm
Thanks for all the input everyone.

I built the mechanism last weekend and wrote the code, but not tested with the mechanism yet- I'm out of town on business.

So this weekend I'll test my code as is, make sure I have the simple version running and then enhance.

Mechanism, btw, is made of Mecanno. A strip on a hinge basically: the middle of the strip sits in the "U" of the opto interrupter, and the free end rests on the electromagnet. Lifting it simulates pushing the arm of the turnstyle, dropping it simulates the next arm clicking home behind you. The strip can easily be lifted even when the magnet is on: that represents forced entry and sets off an alarm.

I'll post more this weekend when I'm home.
551  Using Arduino / Programming Questions / Re: Displaying RTC (DS1307) date and time on LCD on: July 10, 2014, 11:04:46 pm
Just to add another perspective, I use this library which is linked from the Playground. I use it to display the time on OLED display. It might be worth a look.

There's a sketch in the library examples to set the time (it uses the time the sketch was compiled), and another to read it. Dead simple to use.
552  Using Arduino / Programming Questions / Re: Relay not activating – help please on: July 10, 2014, 11:35:05 am
Quote
I think that had better provide a circuit diagram so that we can see how things are wired in your project.

doing some sort of wiring digram will be a pain.


If it's too much of pain to construct a diagram, should that pain become the forum's pain?


553  Using Arduino / Sensors / Re: Need help with Sharp IR Sensor GP2Y0A02YK0F on: July 10, 2014, 10:19:44 am
20cm is the specified near-limit in the datasheet.
554  Using Arduino / Project Guidance / Re: i need advice in my project on: July 10, 2014, 10:06:35 am
Well done for starting to think about your possible project so far ahead of time. Most requests here are for help when the project is due in a week, not a year.

A member of this forum named CrossRoads, wrote this with his wife. Well worth looking at...
555  Using Arduino / Programming Questions / Re: State machine modeling on: July 10, 2014, 02:23:19 am
Yep Robin that's more or less my thinking: I'd go for a state of "Card swiped" as an intermediate step.

So Event: Swipe from State: Locked will give State: Card swiped.

Event: Coin from State: Card swiped will give State: Unlocked.

Event: Swipe from State: Card swiped will remain at State: Card swiped

Event: Timeout from State: Card swiped will revert to State: Locked

Event: Coin from State: Locked will remain at State: Locked (ie card swipe must precede coin insertion.)

This is fun  smiley-cool .... purely academic, and it's clarifying a lot of state machine stuff which is all good.
Pages: 1 ... 35 36 [37] 38 39 ... 294