Show Posts
Pages: [1] 2
1  Forum 2005-2010 (read only) / Syntax & Programs / analog Value's into Array? on: August 11, 2008, 11:26:47 am
Hello everyone,

Quick question for you - I need to pass 5 integers into an array to fill spots
  • - [4] respectively, and constantly update every time the loop is run.
The value's come from a Thermistor, and I'd like to be able to compare array locations 0 and 4, so I can determine if the most current reading is lower than a reading 5 seconds ago. (I'll then be able to tell if something is beginning to cool off ...)

EDIT:
ah .. I think I've got it for the most part - the Smoothing example is quite useful here.

Any other ways would be cool to check out though - cheers
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: question about random function on: September 14, 2007, 01:03:32 pm
ah I see ... thanks for the quick reply!

I'll check out the link.


Also - the analogRead(0) seed in the setup() achieved what I was looking for - it seems to be generating a new list of random numbers every time I reset the program.

cheers mellis!

Code:
long randNumber;
long time;


void setup(){
  Serial.begin(9600);
  randomSeed(analogRead(0));
}

void loop(){
  Serial.print("Time: ");
  time = millis();
  Serial.println(time);
  delay(2000);
  
  randNumber = random(50,300);
  
  Serial.println(randNumber);
}
3  Forum 2005-2010 (read only) / Syntax & Programs / question about random function on: September 14, 2007, 12:36:39 pm
 Just a quick question about the random number function in Arduino - I've noticed that every time the program is reset and starts up again, it will pick the same "random" numbers in the exact order as it did before.....


Is there an explaination for this?
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: perhaps a little help with servo control?? on: September 02, 2007, 04:51:53 pm
Quote
running that many servos on so little current is goign to spell trouble.
You need at least a couple amps to power 9 servos properly.... they draw 1/4A easy.  
They should be on a separate power supply too-- not on the Arduino supply.  

ok thanks, I'll look for another power supply
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: perhaps a little help with servo control?? on: September 02, 2007, 04:17:58 pm
Quote
Q. Was the supply adequate to power all 9 servo's ?


well .. somewhat ... smiley-wink

I'm running a 9v 500Ma power supply - it pushes them all at once, however there is a slight lag time on some of them, and I could see that they're not running at full speed or power.

Leads me to believe that it could be two things - the refresh time in the code is too long for this amount of motors, or I need more amperage.
6  Forum 2005-2010 (read only) / Syntax & Programs / perhaps a little help with servo control?? on: September 02, 2007, 04:06:02 pm
Hello everyone,

Here's my goal, its pretty simple - just a little prototype for a larger project....

I need to be able to control 9 servo's from one board (Decimilia) independently.  I'm a bit new at writing code however, so my approach was to write separate functions for each servo, and then call those functions in a main loop in whatever order was necessary to achieve the desired effect.  

I have some code that simply runs all of them at once, (just a test to see if my power supply was sufficient) -
how could I modify this or re-write the code to get independent control and get to a choreographed sequence of actuations?

Code:

#define SERVOa 13
#define SERVOb 12
#define SERVOc 11
#define SERVOd 10
#define SERVOe 9
#define SERVOf 8
#define SERVOg 7
#define SERVOh 6
#define SERVOi 5


#define MIN_PULSE 600
#define MAX_PULSE 2400
#define DELTA 1800


int lastPulse = 0;
int refreshTime = 20;

long randNumber;

void setup()
{
  int i;
  pinMode(SERVOa, OUTPUT);
  pinMode(SERVOb, OUTPUT);
  pinMode(SERVOc, OUTPUT);
  pinMode(SERVOd, OUTPUT);
  pinMode(SERVOe, OUTPUT);
  pinMode(SERVOf, OUTPUT);
  pinMode(SERVOg, OUTPUT);
  pinMode(SERVOh, OUTPUT);
  pinMode(SERVOi, OUTPUT);
  
  digitalWrite(SERVOa, LOW);
  digitalWrite(SERVOb, LOW);
  digitalWrite(SERVOc, LOW);
  digitalWrite(SERVOd, LOW);
  digitalWrite(SERVOe, LOW);
  digitalWrite(SERVOf, LOW);
  digitalWrite(SERVOg, LOW);
  digitalWrite(SERVOh, LOW);
  digitalWrite(SERVOi, LOW);

  
  Serial.begin(9600);
  for (i=0; i<10; i++)
  {
    digitalWrite(SERVOa, HIGH);
    digitalWrite(SERVOb, HIGH);
    digitalWrite(SERVOc, HIGH);
    digitalWrite(SERVOd, HIGH);
    digitalWrite(SERVOe, HIGH);
    digitalWrite(SERVOf, HIGH);
    digitalWrite(SERVOg, HIGH);
    digitalWrite(SERVOh, HIGH);
    digitalWrite(SERVOi, HIGH);
    
    delayMicroseconds((MIN_PULSE + MAX_PULSE)/2);
    
    digitalWrite(SERVOa, LOW);
    digitalWrite(SERVOb, LOW);
    digitalWrite(SERVOc, LOW);
    digitalWrite(SERVOd, LOW);
    digitalWrite(SERVOe, LOW);
    digitalWrite(SERVOf, LOW);
    digitalWrite(SERVOg, LOW);
    digitalWrite(SERVOh, LOW);
    digitalWrite(SERVOi, LOW);
    
    delay(20);
  }
  Serial.println("servo should be at center");

  delay(20);
}

void loop()

{
  int i;
  static int pulse_width;
  
  randNumber = random(600, 2400);
  delay(3000);
  
  pulse_width = randNumber;
  Serial.println(pulse_width, DEC);
  
 /*
  if (millis() - lastPulse >= refreshTime) {
    digitalWrite(SERVOa, HIGH);
    digitalWrite(SERVOb, HIGH);
    digitalWrite(SERVOc, HIGH);
    digitalWrite(SERVOd, HIGH);
    digitalWrite(SERVOe, HIGH);
    digitalWrite(SERVOf, HIGH);
    digitalWrite(SERVOg, HIGH);
    digitalWrite(SERVOh, HIGH);
    digitalWrite(SERVOi, HIGH);
    
    delayMicroseconds(pulse_width);
    
    digitalWrite(SERVOa, LOW);
    digitalWrite(SERVOb, LOW);
    digitalWrite(SERVOc, LOW);
    digitalWrite(SERVOd, LOW);
    digitalWrite(SERVOe, LOW);
    digitalWrite(SERVOf, LOW);
    digitalWrite(SERVOg, LOW);
    digitalWrite(SERVOh, LOW);
    digitalWrite(SERVOi, LOW);
    
    delay(20);
    
    lastPulse = millis();
  }
}
*/
  
    for (i=0; i<100; i++)
 {
      digitalWrite(SERVOa, HIGH);
      digitalWrite(SERVOb, HIGH);
      digitalWrite(SERVOc, HIGH);
      digitalWrite(SERVOd, HIGH);
      digitalWrite(SERVOe, HIGH);
      digitalWrite(SERVOf, HIGH);
      digitalWrite(SERVOg, HIGH);
        digitalWrite(SERVOh, HIGH);
        digitalWrite(SERVOi, HIGH);

      delayMicroseconds(pulse_width);

      digitalWrite(SERVOa, LOW);
      digitalWrite(SERVOb, LOW);
      digitalWrite(SERVOc, LOW);
      digitalWrite(SERVOd, LOW);
      digitalWrite(SERVOe, LOW);
      digitalWrite(SERVOf, LOW);
      digitalWrite(SERVOg, LOW);
        digitalWrite(SERVOh, LOW);
        digitalWrite(SERVOi, LOW);

      delay(20);
  }
}
 


thanks in advance !!
7  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: September 09, 2007, 06:54:37 pm
EDIT:  nevermind .... figured it out  :o


8  Forum 2005-2010 (read only) / Interfacing / Re: problems with Processing on: March 29, 2008, 09:05:27 pm
AH!!!  ... silly me .... I should have known   :-[

thanks!
9  Forum 2005-2010 (read only) / Interfacing / Re: problems with Processing on: March 29, 2008, 08:48:17 pm
some screen shots to explain what I mean ....



10  Forum 2005-2010 (read only) / Interfacing / problems with Processing on: March 29, 2008, 05:23:04 pm
Hi Guys,

I've just begun figuring out the best way to communicate between Processing and Ardunio ... basically I'd like to graph my incoming data from 5 thermistors ....

All the sample code I've tried has not worked .... what keeps happening is when the Processing sketch is initiated, my analog values become muddled in Arduino.

for instance .. a series of values with a carriage return would read
535
545
555
565
etc .... just fine in Arduino ...

when the Processing sketch is run to attempt to use this data something like this occurs ...

5
454
566544
5456
45
56654
etc ...

which causes the Processing script to simply not read anything coherent and not graph anything at all...

any ideas??
11  Forum 2005-2010 (read only) / Interfacing / Re: dallas temp sensor review and help / (one wire on: September 16, 2007, 06:22:15 pm
Hey man thanks for the reply - I'm sorry I missed that -

I went with your circuit and code .... heres what I'm getting through the serial


28 F8 9D 46 1 0 0 D4 read rom

49 1 4B 46 7F FF 7 10 F6 read scratchpad  T =  36 version: 1


and if i put my hand on the sensor it reads


28 F8 9D 46 1 0 0 D4 read rom

80 1 4B 46 7F FF 10 10 C6 read scratchpad  T =  64 version: 1



the difference being the 36 and the 64

just wondering what exactly all this information is - and how to decipher it (I'm assuming of course that T = is the temp reading)

thanks again!

12  Forum 2005-2010 (read only) / Interfacing / Re: dallas temp sensor review and help / (one wire on: September 16, 2007, 02:07:34 pm
please!?? smiley-grin
13  Forum 2005-2010 (read only) / Interfacing / dallas temp sensor review and help / (one wire) on: September 10, 2007, 06:03:52 pm
ok guys ... I need a hand or two

I've read this entire thread and learned quite a bit about these temp sensors (one wire)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1161557194

however ....

I'd just like to double check on my circuit - if anyone had an image for exactly how to wire these up to the Arduino that would be helpful.

I'm running a DS18B20 (is there a major difference between the B20 and the S20?) with the sample code provided in the Playground and using the necessary OneWire library in 009 programming a new Decimilia.
http://www.arduino.cc/playground/Learning/OneWire


heres my results.....


R=28 F8 9D 46 1 0 0 D4 Device is not a DS18S20 family device.
No more addresses.


So, my first question is .... what are the possible things that could be wrong so that I can start narrowing it down in order to figure out how to use these sensors.

Also, whats your experience been like with these sensors in general (those of you who may have used them) in terms of accuracy?

any help on these things is greatly appreciated.

cheers
14  Forum 2005-2010 (read only) / Interfacing / Re: Servo control - from Processing? on: July 24, 2007, 06:55:36 am
Thanks for the replies.

Yes that seemed to be the case - I switched out the servo for another to test it out and it worked fine.

Going back to the Serial communication - I've got the servo working from keypresses (within the serial monitor) so the serial works fine within Arduino - I'm having a little difficulty on the Processing side - I tell it to send a character "k" for instance upon a specific event , but it does not exactly send that information to Arduino thus not moving the motor.

I'm very new at serial - do I need a carriage return in there to clean up the strings and allow arduino it read it clearly?

perhaps I should do some reading on serial communication - i've searched the site for tutorials, anyone have more?

15  Forum 2005-2010 (read only) / Interfacing / Re: Servo control - from Processing? on: July 22, 2007, 09:07:46 am
I've also just noticed there is something else occurring here....

If I power the board and servo through the USB, a tried and tested code using a potentiometer to move the servo runs perfectly, however that same code does not work correctly when the board is powered with a 9v power source....
There is a massive lag from turning the POT and when the values are actually received by arduino....

stumped on this one  :-/
Pages: [1] 2