Loading...
  Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Delay function on: May 09, 2013, 01:06:28 pm
Hello everyone,

There is probably a post discussing this subject, but I did not find it. So my question : I want to do 1 and 10min delay, using the delay function. I was wondering is it possible to write delay(1*60*100); or it should be written has delay(60000);?

Thanks

M.
2  Using Arduino / General Electronics / Re: Zener voltage divider on: March 01, 2013, 05:00:07 pm
Yes a couple of time in the last 2days

My mind must have skipped the info.

Thx for the answer!

M.
3  Using Arduino / General Electronics / Zener voltage divider on: March 01, 2013, 04:49:59 pm
Hello,

I'm trying to build an external Aref from a Zener Diode voltage divider. In order to select te right resistor I want to know how much current will the Aref pin sink?

Thanks in advance

M.
4  Using Arduino / Programming Questions / Re: Inline println on: November 20, 2012, 04:06:06 pm
I have two questions on this part of the code :
1. Is this used to calculate the size of the array with the position in memory?
2. What is 'a' is some general form to use when defining a variable or a relation?

Code:

#define ARY_LEN(a) (sizeof(a)/sizeof(a[0]))


Thx!

M.
5  Using Arduino / Programming Questions / Re: Inline println on: November 20, 2012, 03:50:33 pm
Thank you everyone,

It was exactly the information I was looking for!

M.
6  Using Arduino / Programming Questions / Inline println on: November 20, 2012, 12:27:32 am
Hello,

I want to know if it is possible to print in array in the serial monitor in the form 0 0 0 0 0 0 for a 6 element array.

Currently I am using the following line of code. Combo_try[6] = {0,0,0,0,0,0}
Code:
Serial.println(combo_try[6]);

What I am getting is :
362
36
0þ0
0
0
0
...

Thanks you

M.
7  Using Arduino / Motors, Mechanics, and Power / Re: Continuous rotation Servo on: November 14, 2012, 02:02:13 pm
Thx Lefty,

I did not think I was buying a servo with extra features. I find these servo Ideal when you need to control the speed! But I guess you are right that without feedback it is impossible to start and stop the motor at exactly the same rotation on both side. I guess that with the addition of a Encoder I could get a response closer to a real servo with the addition of the 360deg rotation.

M.
8  Using Arduino / Motors, Mechanics, and Power / Continuous rotation Servo on: November 14, 2012, 12:21:38 pm
Hello,

I have a continuous rotation parallax servo. I'm trying to reproduce the functionality of a regular hobby servo. Basically I send à 1.6ms pulse for 1sec. and then try to return it to its original position by sending it a 1.4ms pulse for 1 sec. I observe a drift in the starting and ending position. It may be a completely normal situation, but I was not sure why exactly.

Thank you in advance

M.
9  Using Arduino / Programming Questions / Re: Simple servo + button + led Question on: November 14, 2012, 11:48:33 am
digitalRead() returns an int, not a boolean. This debounce code sucks.
I use a boolean, because I read in the doc that digitalRead() returns HIGH or LOW, so the boolean seemed fit.

Quote
It's really hard to tell, from these names, whether currentButton refers to a switch number, a pin number, or a switch state. Better variable names would be in order.
See the new code attach if it makes more sense.

Quote
How is your switch wired?
One leg to pin8 the other to a pull down resistor which is connected to ground.

Quote
After your sketch has been running for 32 seconds, what is going to happen? Look at the millis() documentation again. The function returns an unsigned long for a reason.
Thanks, for that hint went to check in the doc and it always return a unsigned long. Thinking back it may be one of the reason it failed.

Quote
does the same thing, and is guaranteed to work. But, count is a lousy name, since you aren't counting anything.
I changed my code to have the to variable subtract from each other. That also caused me some problem too. I also changed my variable name from count to time.

Quote
Why are you not using the Servo library? It makes dealing with the servo so much easier.
Because I like to program myself basic stuff in order to understand what is happening first. Once I understand what is going on I will either build my own libraries (for fun) or use the one provided.

With the few pointer you provided me the code is now working perfectly fine

Thank You
M.

Code:
nt switchPin = 8;
int ledPin = 13;
int servoPin = 3;

boolean lastButtonState = LOW;
boolean currentButtonState = LOW;
boolean ledOn = false;
boolean motorOn = false;

long time = 0;
long time_0 = 0;

void setup()
{
  pinMode(switchPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(servoPin, OUTPUT);
  Serial.begin(9600);
}

/*------------------------------------------------------------*/
boolean debounce(boolean lastState)
{
  boolean currentState = digitalRead(switchPin);
  if (lastState != currentState)
  {
    delay(5);
    currentState = digitalRead(switchPin);
  }
  return currentState;
}
/*------------------------------------------------------------*/

void loop()
{
  currentButtonState = debounce(lastButtonState);
  if (lastButtonState == LOW && currentButtonState == HIGH && motorOn == false)
  {
    ledOn = !ledOn;
    if (ledOn) {
      motorOn = !motorOn;
    }
  }
 
  lastButtonState = currentButtonState;
  digitalWrite(ledPin, ledOn);
 
  time = 0;
  time_0 = millis();
 
  if (motorOn) {
    motorOn = false;
    while(time - time_0 <= 1000) {
      digitalWrite(servoPin,HIGH);
      delayMicroseconds(1600);
      digitalWrite(servoPin,LOW);
      delay(20);
      time = millis();
    }
  }
  digitalWrite(servoPin,HIGH);
  delayMicroseconds(1500);
  digitalWrite(servoPin,LOW);
  delay(20);
}

10  Using Arduino / Programming Questions / Simple servo + button + led Question on: November 14, 2012, 01:19:22 am
Hello,

I am still quite new to the arduino programming and yesterday I tried to integrate two simple project together. The first one is a piece of code that I wrote to make a continuous servo turn for approximately 1sec. The second one is to light a led with the push of a button. Basically what I want to do is to have my servo rotate for 1sec and the LED turn on. On the second press have simply the LED turn off.

Heres's my code :
Code:
int switchPin = 8;
int ledPin = 13;
int servoPin = 3;

boolean lastButton = LOW;
boolean currentButton = LOW;
boolean ledOn = false;
boolean motorOn = false;

void setup()
{
  pinMode(switchPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(servoPin, OUTPUT);
  Serial.begin(9600);
}

/*------------------------------------------------------------*/
boolean debounce(boolean last)
{
  boolean current = digitalRead(switchPin);
  if (last != current)
  {
    delay(5);
    current = digitalRead(switchPin);
  }
  return current;
}
/*------------------------------------------------------------*/

void loop()
{
  currentButton = debounce(lastButton);
  if (lastButton == LOW && currentButton == HIGH && motorOn == false)
  {
    ledOn = !ledOn;
    motorOn = !motorOn;
  }
 
  lastButton = currentButton;
  digitalWrite(ledPin, ledOn);
 
  int count = 0;
  int count_0 = millis();
 
  if (motorOn == true) {
    while(count <= count_0 + 1000) {
      digitalWrite(servoPin,HIGH);
      delayMicroseconds(1600);
      digitalWrite(servoPin,LOW);
      delay(20);
      count = millis();
    }
    motorOn = false;
  }
  digitalWrite(servoPin,HIGH);
  delayMicroseconds(1500);
  digitalWrite(servoPin,LOW);
  delay(20);
}


Thank you in advance.

M.
11  Using Arduino / Programming Questions / Re: Color of reserved word on: November 12, 2012, 11:55:26 pm
Thank you for your answer,

Quote
2 other options is there are a few themes floating around the forums IE

what is IE?

Thanks,

M.
12  Using Arduino / Programming Questions / Color of reserved word on: November 12, 2012, 10:27:00 pm
Hello everyone,

I have a quick question, I am new using arduino. I was writing some code and I realized that the color of HIGH or OUTPUT did not show a really good contrast on my screen. I was wondering If it was possible to choose which color was displayed?

Thanks,

M.
13  Using Arduino / Project Guidance / Re: Large number of motor to control on: September 20, 2012, 09:41:01 am
Thank you guys!

Quote
Hi, Are you reversing the motors (Like used in the car) or running them only in 1 direction?
Yeah I will need to inverse the polarity in order to run the motors both

The next question is:- do you need speed, direction, brake, current sensing.

For speed you need a pin that can produce PWM does the mega have enough PWM pins?

For current sensing you need a analog pin per motor.
No I do not need speed or current sensing. I only need to say motor 1 +6V, motor 2 -6V or the reverse

Thank you for your answer

M.
14  Using Arduino / Project Guidance / Re: Large number of motor to control on: September 19, 2012, 03:28:12 pm
Thank you for your answers,

Each will consume 1.5amps at +/-6V for 5sec burst. The motors will be used in pair and at no time will both motors of a given pair will have to be actuated together.

Thanks
15  Using Arduino / Project Guidance / Large number of motor to control on: September 19, 2012, 11:34:33 am
Hi everyone,

I have a quick question! I have a small project where I need to control 20 Door lock motor. I was wondering if It could be acheive with 1 arduino mega and 10 motor controller shields.

Thank you

M.
Pages: [1]