Loading...
  Show Posts
Pages: [1] 2 3 ... 13
1  Using Arduino / Project Guidance / Re: PIR sensor with timer, first time and need help on: May 07, 2013, 07:43:07 am
I need to put serial print to determine when motion starts and ends? So it is most probably then sensor and not the coding right? I'm gonna give it a shot and we'll see how it goes..thanks guy

Yes, with the serial print, you can see when motion starts and stops. Or you can do the same thing with an additional LED so you can look at it instead of the computer screen. Your preference. Let us know how it goes.
2  Using Arduino / Programming Questions / Re: How to emit a frequency from an infrared led on: May 06, 2013, 06:04:38 pm
It already does emit that frequency.
3  Using Arduino / Project Guidance / Re: PIR sensor with timer, first time and need help on: May 06, 2013, 05:59:08 pm
You might want to add another led that lights when motion is detected and turns off when there is no motion. This is just for debugging. Or you could use serial print. The reason the light stays on longer than your two seconds may be because the pir sensor is still detecting motion. Depending on your motion sensor, it's on board micro-controller may be programmed that way.
4  Using Arduino / Programming Questions / Re: Controlling a DC-motor simultaneously with two servos on: May 05, 2013, 08:43:09 am
That isn't very much information. Please read this:  http://arduino.cc/forum/index.php/topic,148850.0.html

You need to supply information like the code you are using, schematics of your circuit, information about your components, etc.
5  Using Arduino / Programming Questions / Re: Multiple things at once (millis) on: May 04, 2013, 01:47:57 am
Is that to clean up code or to make the motors turn?
6  Using Arduino / Programming Questions / Re: Multiple things at once (millis) on: May 03, 2013, 10:33:10 am
If you get rid of all the stuff with millis() and toggling the STBY pin, do the motors work correctly? Do you have a hardware or a software problem? I see nothing in the software that would cause the issue you describe.

Yes, If I toggle the STBY pin without the millis () stuff, the motors work as expected. I could probably get it to work if I move the PWMA and PWMB to pins 9 and 10 from pins 5 and 6 to free up timer0, but I would like to get it to work as is.
7  Using Arduino / Programming Questions / Re: Multiple things at once (millis) on: May 03, 2013, 07:30:04 am
It might clean up the code, but I don't know how it would affect the timing problem. Essentially I'm testing what I read in another thread about timer0 and pwm on pins 5 and 6. In theory this should work according to this comment I found in another thread:

micros() and millis() both work using timer0, even when timer0 is doing PWM.
8  Using Arduino / Programming Questions / Multiple things at once (millis) on: May 02, 2013, 09:03:38 pm
I'm trying to follow Nick Gammon's tutorial http://www.gammon.com.au/forum/?id=11411 to get motors to turn and to light a LED. Here is my code:

Code:
const byte PWMA = 5;
const byte AIN2 = 2;
const byte AIN1 = 3;
const byte STBY = 4;
const byte BIN1 = 7;
const byte BIN2 = A4;
const byte PWMB = 6;
const byte RedLED = A5;
// Time periods of blinks in milliseconds (1000 to a second).
const unsigned long Motorsinterval = 5000;
const unsigned long RedLEDinterval = 5000;
// Variable holding the timer value so far. One for each "Timer"
unsigned long Motorstimer;
unsigned long RedLEDtimer;


void setup()
{
  Motorstimer = millis ();
  RedLEDtimer = millis ();
  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);
  pinMode(PWMA, OUTPUT);
  pinMode (STBY, OUTPUT);
  pinMode(BIN1, OUTPUT);
  pinMode(BIN2, OUTPUT);
  pinMode(PWMB, OUTPUT);
  pinMode(RedLED, OUTPUT);
}


void toggleMotors ()
{
  if (digitalRead (STBY) == LOW)
  {
    digitalWrite (STBY, HIGH);
    digitalWrite(AIN1, LOW);  //FORWARD  ****
    digitalWrite(AIN2, HIGH);    //REVERSE IF HIGH
    analogWrite(PWMA,255);
    digitalWrite(BIN1, LOW);  //FORWARD
    digitalWrite(BIN2,HIGH);  //REVERSE IF HIGH
    analogWrite(PWMB,255);
  }
  else 
  {
    digitalWrite (STBY, LOW);
  }

  // remember when we toggled it
  Motorstimer = millis (); 
}  // end of toggleGreenRedLED

void toggleRedLED ()
{
  if (digitalRead (RedLED) == LOW)
  {
    digitalWrite (RedLED, HIGH);
  }
  else
  {
    digitalWrite (RedLED, LOW);
  }
  // remember when we toggled it
  RedLEDtimer = millis (); 
}  // end of toggleRedRedLED


void loop()
{

  if ( (millis () - Motorstimer) >= Motorsinterval)
  {
    toggleMotors ();
  }

  if ( (millis () - RedLEDtimer) >= RedLEDinterval)
  {
    toggleRedLED ();
  }


}

The red LED turns on and off as expected, but the motors never fully turn on. They only twitch about 1/8 of a turn when the red led turns on and again when it turns off.

If I just use a test code to turn the motors on without any sort of timer or delays, they turn as expected.

I'm using a TB6612FNG motor driver.  http://www.pololu.com/catalog/product/713

standalone ATmega 328 on soldered perf board:
http://arduino.cc/en/Main/Standalone

Motord:
http://www.pololu.com/catalog/product/77

Power:
I'm using 6 AA rechargeable NiMH batteries for the motors (input to the motor driver) and a 9v battery to a 7805 regulator decoupled with .1uF and 22uF on the input and 100uF and 10uF on the output.

Any suggestions would be greatly appreciated. 




9  Using Arduino / General Electronics / Re: A Perfectly reasonable and good place to spend money.. on: April 20, 2013, 11:45:36 pm
I agree Doc. It looks good to me. I'm going to give it a try.
10  Using Arduino / Project Guidance / Re: Tethering Arduino to mobile phone using Wifi on: April 20, 2013, 08:30:10 pm
Take a look at PDA net for Android. It costs about $8.
http://pdanet.co/

I've never used it to connect to Android, but it's worth taking a look at.
11  Using Arduino / Motors, Mechanics, and Power / Re: using timers & pwm & servo at the same time on: April 20, 2013, 08:38:50 am
 I doubt anybody will be willing to do your work for you if you don't at least try your own code and post it here. Then people will be willing to give you constructive criticism.

You need to supply more information. Are you using an h-bridge?

http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM
12  Using Arduino / General Electronics / Re: Toggle pin state with push button on: April 15, 2013, 07:51:24 pm
Thanks, I do know the difference between analog and digital. Perhaps my message was not clear.

Since i have run out of digital pins......
I am trying to read an analog voltage on the analog inputs and if the voltage is more than a particular value (4.0V according to the code), then I say it is "on" by setting a variable called AnalogState to 1 and if below, I say it is off and set it to zero. I am using an analog threshold to decide if something is true or false. By using a push switch to put ~5 volts into the analoginput, I can detect whether the button has been pushed. I am now looking for a nice way to ensure that the code responds to a proper press and not noise and some verification that putting a resistor onto the analog input in the same way that a resistor is used to pull up or pull down a digital pin will not cause any damage to the arduino.

 Nick

 AnalogReading = analogRead(WhichButton);
   if (AnalogReading > 4.0)

look up TTL logic level. It's digital.

13  Using Arduino / General Electronics / Re: Toggle pin state with push button on: April 14, 2013, 02:21:40 pm
Here's a good tutorial for button state:  http://www.ladyada.net/learn/arduino/lesson5.html

Because i am limited in the number of digital pins I can use for this task (I have 4 push buttons) and need to control most of the
digital outputs of the arduino uno, I thought I could use the analogread function instead to see if the input to one of these pins is high or low.

Analog pins can be used as digital pins. Use digitalRead instead of "analogread."

I'm not sure what "AnalogState" is or where you are going with that, but you might want to read a couple more tutorials and rethink your game plan with that code.

Maybe do a little research on the difference between analog and digital.
14  Using Arduino / Motors, Mechanics, and Power / Re: How to efficently switch a 5V 800mA load? on: April 07, 2013, 08:34:59 pm
Here's a good tutorial:  http://bildr.org/2012/03/rfp30n06le-arduino/

You should also add a 100 Ohm resistor in series between the mosfet gate and the arduino pin that you are using to drive the mosfet  gate. That isn't included in the tutorial, but it's good policy.
15  Using Arduino / General Electronics / Re: Power standalone atmega328 and servo motor via 9V battery on: April 03, 2013, 08:30:34 pm
Four AA batteries won't work with your 7805 because you'll need at least 7 volts input (look up your specific 7805's data sheet for specifics). I use 6 AA batteries for input. A 7805 and a 6V regulator in parallel from your 6AA batteries would probably work ok. Don't forget to decouple. http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html
Pages: [1] 2 3 ... 13