Show Posts
Pages: 1 ... 18 19 [20] 21 22 ... 24
286  Using Arduino / Programming Questions / Re: LED Light Sensor Circuit Inverted on: January 02, 2013, 04:31:23 pm
Hey that's great!  Good luck!
John
287  Using Arduino / Programming Questions / Re: Programming traffic light, want multiple loops at random on: January 02, 2013, 12:19:03 pm
...
So, I'm having to learn as I go. I haven't gotten to arrays yet; I've just made it past digitalWrite, integer setups and delay :-P

Don't count yourself as past digitalWrite yet unless you understand pinMode smiley

Cheers,
John
288  Using Arduino / General Electronics / Re: Simple backup power on: January 02, 2013, 10:10:46 am
What are the power requirements? Volts, amps ...

In my case it was 7-12V and about 150ma.  Don't know about the OP.
289  Using Arduino / General Electronics / Re: Simple backup power on: January 02, 2013, 09:55:45 am
I have sometimes used a 12V lawnmower or motorcyle battery with a Harbor Freight trickle charger ($5).

Cheers,
John
290  Using Arduino / Programming Questions / Re: LED Light Sensor Circuit Inverted on: January 02, 2013, 09:42:13 am
Also it might simplify your debugging if you use a sketch like this

void setup(){ pinMode(9,OUTPUT); digitalWrite(9, HIGH); }
void loop(){}

Cheers,
John
291  Using Arduino / Programming Questions / Re: LED Light Sensor Circuit Inverted on: January 02, 2013, 09:39:12 am

If that is all the case then it may be that your circuit is not actually as you last posted?
If you remove the resistor lead from D9 and apply +5 to that lead, does the LED light?
If not, if you apply GND to that lead, does it light?
You know that the LED must be put in the right way and not backwards, right?

John
292  Using Arduino / Programming Questions / Re: Programming traffic light, want multiple loops at random on: January 02, 2013, 09:16:39 am

byte* sequence = {0,2,1,2};
that means "green light, pause, red light, pause".


Since he has "Arrow" lights, I would think he would want cases where he could have more than one on at the time, so maybe

byte sequence[] = { 0b00001, 0, 0b00010, 0, 0b00011, 0};
that means "green light, pause, red light, pause, green and red light, pause...".

Cheers,
John

293  Using Arduino / Programming Questions / Re: LED Light Sensor Circuit Inverted on: January 02, 2013, 09:03:32 am
Hi All

I'm struggling to understand where I'm going wrong with a very simple circuit.

I have light sensitive resistor that is being used to switch on an LED when the light level drops below a fixed value.  I'm monitoring the analogue value returned by the sensor and the value being used to set the LED via the serial window.  The values are as expected so I think the error is in the very simple LED circuit.

Code:
  int val = analogRead(sensePin);
  boolean ledVal = LOW;
  if (val < 750)
  {
    ledVal = HIGH;
  }
  else
  {
    ledVal = LOW;
  }
  digitalWrite(ledPin,ledVal);

  Serial.println(ledVal);

  delay(500);

}

The LED is being switched on and off as the light levels change but the wrong way around; it is on when the ledVal is LOW and off when the ledVal is HIGH.

From what I can tell, val will be great when there is much light, and val will be small when there is little light.  Therefore, the code above will cause the led to light when the ambient light is low.  Is that what it's doing?  If you want the opposite, code
Code:
if (val < 750)
  {
    ledVal = LOW;
  }
  else
  {
    ledVal = HIGH;
  }

Hope this helps!
John
294  Using Arduino / Programming Questions / Re: Too many "if" statements? on: January 02, 2013, 07:37:50 am
Do you know of a way to make

Code:
Udp.write(F("Amaretto Mist- Serve with a lime wedge.  Enjoy!"));
work just like
Code:
Serial.print(F("Amaretto Mist- Serve with a lime wedge.  Enjoy!"));
?
...
ALTERNATIVELY- can the Udp.write send a string instead?  (I can't seem to get it to.)

I think you may be able to write a function in your own sketch something like this:
Code:
   void udpWrite( const __FlashStringHelper *f) {
Udp.beginPacket(iPhoneIP,iPhonePort);
Udp.write((const char *)f);    // Send Message back to iPhone
Udp.endPacket();
   }
and then call it like this
Code:
   kahlua15(); vodka15(); End();
   udpWrite( F("Klingon koffee- Serve on the rocks.  I know... too late!"));

But I'm not sure of the details on this, I have never messed with that technique before.  I'm sure others here have and can help with troubles with it...

John
295  Using Arduino / Programming Questions / Re: Add to an integer on: January 01, 2013, 10:31:29 pm
Or the obscure and unnecessarily complicated:
Code:

  i -=- 1 ;

Love it!  I will have to use this in my next project!!
296  Using Arduino / Programming Questions / Re: Blink Without delay help again. on: January 01, 2013, 10:20:03 pm
...
The constructor will be called before the init() function is called. It is the init() function that sets up the hardware, so calling pinMode() before init() is a waste of time.
...

I thought of that but found that pinMode() was effective.  This was on a Teensy 2 btw,  so I'm not sure if its the same on an Uno, etc.

I suppose it's "undefined" or uncertain whether it should/could/would work or not, so I agree a separate setup() method is best.

Cheers,
John
297  Using Arduino / Programming Questions / Re: Too many "if" statements? on: January 01, 2013, 09:42:31 pm
Looks good Jim!  Where did you get that iOS UI app?

I corrected the functions, paste these instead:
Code:
//////////////////////////////// Warning Light Blink ///////////////////////////

void flashdrink(byte &amt, byte flashcount , int min, int max){
  if ( amt > max) amt = 0;
  if ( amt >= min) {
    flash( flashcount);
    delay( warn);
  }
}

void flashdrink(byte &amt, byte flashcount)
{  flashdrink( amt, flashcount, 180, 190); }

void flash(byte flashcount){
  for (byte x = 0; x <= flashcount; x++)  {
      digitalWrite(LED, 1);
      delay (250);
      digitalWrite(LED, 0);
      delay (250);
  }
}

Then your // W A R N I N G  L I G H T S /// can look like this:
Code:
flashdrink(vodka, 1);
flashdrink(rumdk, 2);
flashdrink(whiskey, 3);
flashdrink(gin  , 4);
flashdrink(brandy, 5);
...
flashdrink(water, 22);

Cheers!
John

P.S. you asked about the &amt. Without it, a copy of the value (e.g. vodka) gets sent to the parameter "amt" in the function.  With the &, a reference to the "location" of where the value is stored, is sent to the amt parameter.  The difference is that reference allows the function code to change the value of "vodka" (reset it to zero).
298  Using Arduino / Networking, Protocols, and Devices / Re: Making internet interaction universal on: January 01, 2013, 05:41:00 pm
The short answer is to forward a port on your router.  What kind of router do you have?

John
299  Using Arduino / Programming Questions / Re: Add to an integer on: January 01, 2013, 05:37:23 pm
Hello I would like to know ad +1 to integer. Does anybody know how to do that?

http://arduino.cc/en/Reference/Arithmetic
300  Using Arduino / Programming Questions / Re: lil help please on: January 01, 2013, 04:52:07 pm
OK I think I got it yay.. here's what I did.
Code:
...

And what happened when you ran it?

John
Pages: 1 ... 18 19 [20] 21 22 ... 24