Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Troubleshooting / Re: Code question on: July 02, 2009, 01:38:19 pm
Removing the abs() call should take care of the problem. With it in, the delta from light to dark and dark to light are always positive and greater than TRIGGER_THRESHHOLD, so each transition causes a trigger.

if (abs(newLightningVal - lightningVal) > TRIGGER_THRESHHOLD)

will become

if ((newLightningVal - lightningVal) > TRIGGER_THRESHHOLD)

I'm making a assumption that the analog value for light is greater than the value for dark. If it's the opposite, just swap the values in the equation to this:

if ((lightningVal - newLightningVal) > TRIGGER_THRESHHOLD)
2  Forum 2005-2010 (read only) / Troubleshooting / Re: Arduino 16 and Apple new Java update on: June 16, 2009, 11:10:50 am
Select the application file in the Finder and then Get Info on it by either selecting "Get Info" in the File menu, or hitting cmd-I. In the info window, check the, "Open in 32 Bit Mode" checkbox and close the window. Now it should work.
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: String to int function on: November 30, 2010, 06:51:50 pm
The buffer needs to be large enough to hold the trailing NULL that is the end-of-character marker for the string. If the String contains "123" the whole String will not be copied into buffer by toCharArray, if buffer is only 3 elements long.

Oops! Forgot about the NULL.
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: String to int function on: November 30, 2010, 04:55:17 pm
The docs for toCharArray() are incorrect. I think this should take care of it for you,

int Str2int (String Str_value)
  char buffer[3]; //max length is three units
  Str_value.toCharArray(buffer, 3);
  int int_value = atoi(buffer);
  return int_value;

though I haven't actually tried it.
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: First project on: April 21, 2010, 04:50:42 pm
The other thing I noticed is that
if(temperature = 90)
should be
if(temperature == 90)
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: Question about some values? on: August 31, 2009, 11:53:00 pm
Check the documentation here, The max value should be one more the largest random value you want.
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: Help with HM55B Compass on: June 19, 2009, 05:54:33 pm
Forgot about map(). Definitely the way to go.
8  Forum 2005-2010 (read only) / Syntax & Programs / Re: Help with HM55B Compass on: June 19, 2009, 01:59:46 pm
Assuming angle contains a value between 0 and 359:

char* directions[]={"N", "NE", "E", "SE", "S", "SW", "W", "NW"};


Beware, though, I haven't been able to actually try it.
9  Forum 2005-2010 (read only) / Syntax & Programs / Re: problem with loop on: February 11, 2009, 04:36:10 pm
I can see a couple of problems, but the reason the loop never gets repeated after the LEDs are turned off by the tilt sensor, is the value of i is now equal to num_pins or 4. When you repress the push button, it tries to turn on pins[4] then pin[5], etc.. The variable i needs to get reset. Also, the initialization of the pins to LOW, should go in setup since it only needs to happen once. Here's some code that should work. Be aware I haven't actually tried it yet, so I could have easily made a mistake.

void setup()
  // add this to the setup
  for(int i = 0; i < num_pins; i++)
    digitalWrite(pins[i], LOW); // initialises state of the led at the i array position.

void loop()
   val = digitalRead(inPin);            // read input value of push button
  val2 = digitalRead(inPin2);            // read input value of tilt switch
  int i;

  if(val == LOW)  // following code is executed if button is pressed
    for(i = 0; i < num_pins; i++)      // turn on LEDs one by one
      digitalWrite(pins[i], HIGH);
      delay(200);            // wait
  if(val2 == 1)   // following code is executed if tilt switch is moved
    for(int i = 0; i< num_pins; i++)
    digitalWrite(pins[i], LOW);      // turns LED off
10  Forum 2005-2010 (read only) / Interfacing / Re: Heart/Pulse sensor? on: May 06, 2010, 05:16:42 pm
I played around with the Polar Heart Rate Module - RMCM01 interfaced to an Arduino. It was fairly easy to get working, but haven't (yet) done anything more than sending data to the Serial Monitor.
11  Forum 2005-2010 (read only) / Workshops / Re: I am looking for Arduino classes in San Francisco on: January 03, 2011, 12:54:18 pm
TechShop <> just opened a branch in downtown San Francisco, and they offer a couple of basic Arduino classes.
12  Forum 2005-2010 (read only) / Workshops / Re: Bay area Arduino meet @ TechShop, Sat. 1/16/2010 on: January 08, 2010, 01:01:42 pm
It's happening at exactly the same time as the Laser meetup @ TechShop.  smiley-sad
13  Forum 2005-2010 (read only) / Workshops / Re: Beginners Arduino Workshop in San Francisco on: April 26, 2009, 04:16:22 pm
Check out the Arduino classes available at the TechShop
Pages: [1]