Show Posts
Pages: [1] 2 3 ... 14
1  Topics / Robotics / Re: Has anyone tried the "Ultrasonic Smart Car Kit" from HobbyKing? on: September 28, 2013, 07:25:24 am
Please post some code and the steps you are making in your progress and we can steer you in the right direction. Right now it sounds to me as if you are wanting someone to give you all the answers to you so that you can give them to your son. How does he (or you) learn that way?
2  Using Arduino / Sensors / Re: Analog Read and PWM conflict on: September 28, 2013, 06:57:24 am
Is the power for your lights supplied through your Arduino or a separate source? In order for anyone to do any kind of meaningful speculating/troubleshooting, you need to supply your full code and a schematic.
3  Using Arduino / Sensors / Re: Multiple XL-Maxsonar reading on: September 27, 2013, 07:07:03 pm
Here are a couple links that can help you:
analogRead? It looks as though you have a mixture of analog and PW modes in your code. If you are trying to use your sensor in PW mode, then you need to use the PW pins on the Arduino, not the analog pins.

Also note the mode filter code example in the Arduino Playground link. It works much better than averaging.  
4  Using Arduino / Sensors / Re: robot with 3 ultrasonic sensors on: September 05, 2013, 08:16:26 pm
5  Using Arduino / Programming Questions / Re: Multiple things at once (millis) on: July 03, 2013, 07:25:29 pm
Disconnecting the wires to one of the motors didn't solve the problem, but it affected the behavior. Sometimes the circuit will behave as expected with the one motor turning on for 5 seconds while the led light turns on for five seconds. Other times the light will blink on and off at five second intervals with the motor turning just an eigth turn or so (or not at all). Sometimes they just both stay on constantly until I press the reset.

For the power supply to the motors, I use 6 AA NiMH batteries. (two packs of three wired in series, cheapos) Is it possible that the wires are too skinny? I don't know the gauge, but I'm sure you all are familiar with those. Probably about 28.

The rest of the circuit is described above.
6  Using Arduino / Project Guidance / Re: Using PWM to control 12v 1.5 amp dc motor on: July 02, 2013, 10:48:32 am

This link assumes that your motor only needs to turn in one direction. An N-Channel MOSFET is what you want.

 If it needs forward and reverse, you'll need a motor controller. This one is somewhat common, cheap, and easy to program:
7  Using Arduino / Motors, Mechanics, and Power / Re: Driving 4 small geared motors on: July 02, 2013, 07:17:39 am
If you use the TB6612FNG, wire the diodes (schottky or 1N4001) like in this picture for counter emf protection. It will protect your circuit from damage and help your sketch to behave the way you intended.
8  Using Arduino / Programming Questions / Re: Multiple things at once (millis) on: May 28, 2013, 11:45:04 am
I'm sure you're right about it being an electrical problem, but it baffles me. Both motors work fine without the "millis" in my code. For example if I just use delay. or just write the code to turn the motors on without stopping them.

Wouldn't you think 6 fully charged AA NiMH batteries would be fine for those motors? But yes, I will try disconnecting a wire to one of the motors and see if that works. I will also try commenting out part of the code so that only one motor turns on and off with the LED blinking.

Also I will try all this with an arduino board instead of the stand alone 328 to see if that works.
9  Using Arduino / Programming Questions / Re: Multiple things at once (millis) on: May 28, 2013, 05:56:35 am
I'm using this circuit up to and including the ftdi I just use male header pins to plug the ftdi board into. That gives me temporary power to the circuit and allows me to use the serial monitor to debug when I'm not using the 9v described below. I disconnected the AREF pin as suggested in an unrelated thread, but that didn't help my problem.

I'm also 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 for the microcontroller.
10  Using Arduino / Programming Questions / Re: Multiple things at once (millis) on: May 27, 2013, 07:26:14 pm
const byte PWMA = 10;
const byte AIN2 = 2;
const byte AIN1 = 3;
const byte STBY = 4;
const byte BIN1 = 7;
const byte BIN2 = A4;
const byte PWMB = 9;
const byte RedLED = A5;
// Time periods of blinks in milliseconds (1000 to a second).
unsigned long Motorsinterval = 5000;
unsigned long RedLEDinterval = 5000;
unsigned long timeinterval = 2000;
// Variable holding the timer value so far. One for each "Timer"
unsigned long Motorstimer;
unsigned long RedLEDtimer;
unsigned long timer;

void setup()
  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);
  pinMode(PWMA, OUTPUT);
  pinMode (STBY, OUTPUT);
  pinMode(BIN1, OUTPUT);
  pinMode(BIN2, OUTPUT);
  pinMode(PWMB, OUTPUT);
  pinMode(RedLED, OUTPUT);
  digitalWrite(AIN1, LOW);  //FORWARD  ****
  digitalWrite(AIN2, HIGH);    //REVERSE IF HIGH
  digitalWrite(BIN1, LOW);  //FORWARD
  digitalWrite(BIN2,HIGH);  //REVERSE IF HIGH
  Motorstimer = millis ();
  RedLEDtimer = millis ();

void toggleMotors ()
  if (digitalRead (STBY) == LOW)
    digitalWrite (STBY, HIGH);
    digitalWrite (STBY, LOW);


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

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

void loop()
  if ( (millis() - timer) >= timeinterval)
    Serial.print("Time:   ");
    timer = millis ();

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

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


I cleaned up the code a little as suggested and added Serial.print for debugging. Also I changed the PWM pins from 5 and 6 to 9 and 10. I am also attaching a screenshot of the serial monitor.

The motors still only twitch a little, but the LED behaves as expected by turning on for 5 seconds then off for 5 seconds. After a few cycles the motors will turn on indefinitely. AS evidenced by the screenshot, the program appears to be resetting itself.

As I mentioned earlier,  The program behaves as expected if I only use delay instead of millis (motors only). Could it be that my crystal oscillator is damaged? Unfortunately I don't have a spare to test that. Also, this circuit is comprised of a standalone ATmega 328.

11  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.
12  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.
13  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.
14  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:,148850.0.html

You need to supply information like the code you are using, schematics of your circuit, information about your components, etc.
15  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?
Pages: [1] 2 3 ... 14