Show Posts
Pages: 1 [2] 3 4 ... 14
16  Using Arduino / Sensors / Re: Too much variations in temperature? on: July 06, 2013, 12:57:44 pm
Quote
average 3 measurements taken in quick succession

I've handsome good luck with that, so you might want to try it.

I also had a similar problem running the circuit from the USB port power. I recall that things got better when I also connected my wall wart.  [faint memory...]
17  Using Arduino / Sensors / Re: Too much variations in temperature? on: July 06, 2013, 12:07:45 am
Hi Levon,

Before we go too far, we should probably see your code to make sure it's doing what you think it's doing.  Copy it and paste it in a reply, select the code and then select the # icon above to put it in a code block.

What you are seeing might be the result of a code error.

Pat.
18  Using Arduino / Programming Questions / Re: Passing an array into function and returning only one of the original elements on: June 30, 2013, 09:20:44 pm
You aren't passing in an array.  try:

int secondMAX(int *B)
19  Using Arduino / General Electronics / Re: Im new and i already love arduno on: June 25, 2013, 06:14:35 pm
Most Arduino books focus on programming concepts and basic electronics.  I have not seen any that focus solely on the innards of the Arduino, although someone may mention one.

I don't think you will need to understand the board itself before enjoying it.  I have learned quite a bit about microcontrollers by using mine.

Pat.
20  Using Arduino / General Electronics / Re: Im new and i already love arduno on: June 25, 2013, 05:38:40 pm
Welcome El Sonador!

There are a lot of good books on programming the Arduino, one of my favorites is the Arduino Cookbook.  It has a lot of easy-to-follow examples and good explanations.

Pat.
21  Using Arduino / Motors, Mechanics, and Power / Re: Very New Need Help on: June 24, 2013, 08:26:56 pm
Absolutely!
22  Using Arduino / Motors, Mechanics, and Power / Re: Very New Need Help on: June 24, 2013, 08:21:02 pm
Hi Jamie,

Welcome to the wonderful world of Arduino!

As you are a beginner, I'd like to suggest that you first try some simpler circuits and sketches.  First check out the examples on his site, and get some books.  One excellent book is the Arduino Cookbook.

Enjoy!
Pat
23  Using Arduino / Sensors / Re: Temp sensor giving unstable readings on: June 24, 2013, 08:58:55 am
Sure, there are 2 basic problems:

1) the key to your stability problem is the samples array: you declare samples as an array of 5 floats, but use it as a scalar variable instead.  By changing the value of samples, rather than changing the array contents, you are changing the memory location that the array points to.  (The more correct explanation is based on "pointer math" which I will jump over to keep the answer short and simple.)

The code I suggested doesn't need an array.  The main loop runs often enough, and the temp won't change erratically enough, to store your samples in an array and keep a running average as a filter.

2) my code recommendation simply takes 5 samples, 10ms apart, in a loop, and then averages them afterwards.

Take a look at this:

Code:
Here is my updated code.
 #define RELAY_PIN 3
const int temperaturePin = 0;
#define NUMSAMPLES 5
float sumOfSamples;

const int targetTemp = 22; // degrees C

void setup()
{
  pinMode(RELAY_PIN, OUTPUT);
  Serial.begin(9600); // open serial
  sumOfSamples=0.0;
}

void loop()
{
  float voltage, degreesC, degreesF;
  float average;
 
   sumOfSamples=0.0;

  // take N samples in a row, with a slight delay
   for (int i=0; i< NUMSAMPLES; i++) {
   voltage = getVoltage(temperaturePin);
   sumOfSamples += voltage;    // create running sum of samples
   delay(10);  // wait a little to spread out samples to filter measurement noise
  }
 
  average = sumOfSamples / NUMSAMPLES;
 
  degreesC = ((average) - 0.5) * 100.0;
  degreesF = degreesC * (9.0/5) + 32.0;
 
  Serial.print("voltage: ");
  Serial.print(average);
  Serial.print("  deg C: ");
  Serial.print(degreesC);
  Serial.print("  deg F: ");
  Serial.println(degreesF);
 
 
     if (degreesC <= targetTemp) {
      Serial.println("Not warm enough");
      digitalWrite(RELAY_PIN, HIGH);
     }
    else {
      digitalWrite(RELAY_PIN, LOW);
      Serial.println("too hot");
    }
   
  delay(500);  // wait here before taking another measurement
}

float getVoltage(int pin)
{
  return (analogRead(pin) * 0.004882814);  // add comment explaining this
}
24  Using Arduino / Sensors / Re: Temp sensor giving unstable readings on: June 23, 2013, 08:38:41 pm
Hi shampoohat,

That's not doing what you think... Look at this as an example of what you need to do:

Code:
  // take N samples in a row, with a slight delay

average=0;
voltage=0;

for (n=0; n<NUMSAMPLES; n++)
{
  voltage += getVoltage(temperaturePin);
  delay(10);
}

average = voltage / NUMSAMPLES;

Let me know if this doesn't make sense.

Pat.
(Fellow brewer/vintner)
25  Using Arduino / General Electronics / Re: Arduino To Trigger Transistor - Resistor Needed? on: June 22, 2013, 07:05:33 am
Quote
So is it possible to use a NPN transistor to...

Google "transistor as a switch" and you'll find a lot of useful material. Most of it is fairly easy to read and understand.

Pat.
26  Using Arduino / Programming Questions / Re: Can I keep logging a sensors data to an sd card while the arduino is in delay on: June 21, 2013, 10:23:47 pm
Well... It's probably not really doing what you think, with those { } errors.

Think of them as enclosing blocks of code that you want to treat as a single block. For example, an if statement will only control the one-single-statement that follows it. So if you want it to control multiple lines of code, they ALL need to be within the braces.  Ditto for the else.

If (some condition)
  X;
  Y;
  Z;

The if only controls X, and the other lines will ALWAYS execute.  If you want them all controlled, enclose them as follows:

If (some condition)
{
  X;
  Y;
  Z;
}
27  Community / Exhibition / Gallery / Re: LED sign and LED strip display sensor data with color changes on: June 21, 2013, 10:09:50 pm
Hi hib1,

That's a nice little project! Did you design the PCB yourself? With what software?

Pat.
28  Using Arduino / Project Guidance / Re: 4servo on: June 21, 2013, 10:01:11 pm
It depends on the servos. What kinds do you have? You should also be able to find that information on their spec sheets.  Most ranges are  0-180 degrees (or a little less, like 10-170 degrees).  The positions are set by sending them short pulses that correspond to desired angles.
29  Using Arduino / Project Guidance / Re: 4servo on: June 21, 2013, 09:52:19 pm
Hi noga,

Go check the links that BillHo included. The Arduino site has a lot of examples to use.

Have you programmed the Arduino before?  If not, go look at the tutorials on the site for additional information.  Good stuff!

Pat.
30  Using Arduino / Motors, Mechanics, and Power / Re: Servo with Transistor problem. on: June 21, 2013, 09:39:34 pm
It doesn't sound like a transistor problem - it sounds like a code problem.  How are you controlling the servo?  Can we see the code?

Paste it in a reply, select it, and then select the # icon above to put it in a code block.

Also, follow this thread (going on now):
http://forum.arduino.cc/index.php?topic=173380.msg1287859#msg1287859
Pages: 1 [2] 3 4 ... 14