Show Posts
Pages: [1]
1  Using Arduino / Motors, Mechanics, and Power / Re: Motor shield - reverse rotation not working for one of the outputs on: March 11, 2013, 02:30:23 pm
See attachment for wiring (the motor shield is slightly different, but has the same pins).


#include <IRremote.h>
#include <SimpleTimer.h>

SimpleTimer timer;

int MA_1=1;
int MA_2=2;
int MB_1=3;
int MB_2=4;
int MA_E=5;
int MB_E=6;

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
unsigned long irvalue;
unsigned long irvalue_prev;

unsigned long IRforward = 0xFF9867; // 100+
unsigned long IRbackward = 0xFFB04F; // back
unsigned long IRleft = 0xFF22DD; // prev
unsigned long IRright = 0xFF02FD; // next
unsigned long IRbeep = 0xFFE21D; // mute
unsigned long IRstop = 0xFFA25D; // power
unsigned long IRdecc = 0xFFE01F; // -vol
unsigned long IRacc = 0xFFA857; // +vol
unsigned long IRrepeat = REPEAT;

int moveTimer;

int moveSpeed = 150;

void setup() {
  irrecv.enableIRIn();        // Start the receiver

  pinMode(MA_1, OUTPUT); 
  pinMode(MA_2, OUTPUT); 
  pinMode(MB_1, OUTPUT); 
  pinMode(MB_2, OUTPUT); 
  pinMode(MA_E, OUTPUT); 
  pinMode(MB_E, OUTPUT);   

void loop() {
  if (irrecv.decode(&results)) {
    irvalue = results.value;
    if (irvalue == IRrepeat && irvalue_prev)
      irvalue = irvalue_prev;
    if (irvalue == IRforward)
    if (irvalue == IRbackward)
    if (irvalue == IRstop)
    if (irvalue == IRdecc)
    if (irvalue == IRacc)
    irvalue_prev = irvalue;
    irrecv.resume();          // Receive the next value

void moveForward() {
  Serial.println("moving forward");
  digitalWrite(MA_1, HIGH); 
  digitalWrite(MB_1, HIGH);     
  digitalWrite(MA_2, LOW); 
  digitalWrite(MB_2, LOW);
//  digitalWrite(MA_E, HIGH);
//  digitalWrite(MB_E, HIGH);
  analogWrite(MA_E, moveSpeed);
  analogWrite(MB_E, moveSpeed);

void moveBackward() {
  Serial.println("moving backward");
  digitalWrite(MA_1, LOW);     
  digitalWrite(MA_2, HIGH);   
  digitalWrite(MA_E, HIGH);
//  digitalWrite(MB_1, LOW);     
//  digitalWrite(MB_2, HIGH);   
//  digitalWrite(MB_E, HIGH); 

void moveTurn() {
  digitalWrite(MA_1, HIGH); 
  digitalWrite(MB_1, LOW);   
  digitalWrite(MA_2, LOW); 
  digitalWrite(MB_2, HIGH);   
  analogWrite(MA_E, moveSpeed);
  analogWrite(MB_E, moveSpeed);

void setMoveTimer(int timeOut) {
  moveTimer = timer.setTimeout(timeOut, stopMovement);

void stopMovement() {
  digitalWrite(MA_1, LOW);
  digitalWrite(MB_1, LOW); 
  digitalWrite(MA_2, LOW);
  digitalWrite(MB_2, LOW); 
  digitalWrite(MA_E, LOW);
  digitalWrite(MB_E, LOW); 

void addSpeed(int speed) {
  moveSpeed = moveSpeed + speed;
  if (moveSpeed <= 100)
    moveSpeed = 10;
  else if (moveSpeed > 255)
    moveSpeed = 255;

Thanks! smiley I have inspected the shield, doesn't show any visible sign of bad soldering.
2  Using Arduino / Motors, Mechanics, and Power / Re: Driving a motor shield from external power on: March 10, 2013, 01:42:59 pm
Thanks, works like a charm (except this issue:,153427.0.html)

Thanks again!
3  Using Arduino / Motors, Mechanics, and Power / Motor shield - reverse rotation not working for one of the outputs on: March 10, 2013, 01:41:51 pm
I have bought the following motor shield:

The controller works fine, except that for one of the motors the reverse rotation doesn't work! There's a very very small movement when I do the following in arduino:
  digitalWrite(IN1, LOW);     
  digitalWrite(IN2, HIGH);   
  digitalWrite(ENA, HIGH);

For the other output, it works fine (reverse):
  digitalWrite(IN3, LOW);     
  digitalWrite(IN4, HIGH);   
  digitalWrite(ENB, HIGH);

Also for IN1 and IN2, the following works (rotate forward):
 digitalWrite(IN1, HIGH); 
 digitalWrite(IN2, LOW); 
 digitalWrite(ENA, HIGH);

Only for IN1 and IN2, the reverse rotation doesn't work. smiley-sad Any ideas why?

Thanks a lot!

Best regards,
4  Using Arduino / Motors, Mechanics, and Power / Re: Driving a motor shield from external power on: March 05, 2013, 01:31:53 pm
DOH! smiley
How could I have missed this?
Indeed, the ground was not connected to Arduino. Somehow I forgot about this.
But now it works like a charm. Thanks!

One more question if you don't mind: for me it's not that clear from the description what are the PWM pin for the motors? Is it IN1 and IN3?
5  Using Arduino / Motors, Mechanics, and Power / Driving a motor shield from external power on: March 05, 2013, 12:33:03 pm

Sorry for the newbie question (or this is how this might sound like) but I cannot seem to understand the following situation: I cannot power this motor shield from external power:

I have both motors hooked to the right place, also the 4 control pins (IN1-IN4) are connected to arduino where I instruct both of them to rotate:

This works fine as long as I power the motor shield from +5V and GND pins of the Arduino. BUT when I connect the +5V and GND (I also tried it first with the 12V input) directly to a 9V battery, the motors don't move at all, but the red light indicating power does light up, only the motors don't move. I tried removing the 5V, also didn't make any difference. And here comes the stranges part (at least to my basic knowledge): if I connect the +5V and GND of the motor shield to the SAME 9V battery that powers Arduino, the motors move! Why is connecting the motor shield to the same battery that Arduino is using different than connecting it to a separate 9V battery? Again, if I connect the shield directly to the +5V and GND pins of Arduino, the motors move (only not that fast) OR if I connect to the +/- terminals of the SAME battery that is connected to arduiono, it works, but using a separate battery it doesn't move, just the red light is lit up.

The motors that I use:

I cannot seem to understand this, so some help would be really welcome. smiley

6  Using Arduino / Motors, Mechanics, and Power / Re: Fried motor contoller? on: July 01, 2012, 03:28:26 am
Many thanks guys for the very detailed and helpful responses! smiley

I have now attached an image of my board, also how I tried now to hook it up with the simplest setup (standalone, 1 motor).
It does not work. The leds light up, but the motor is not moving.
On the image you see a 4xAA rechargable (thus 4,8V in total) battery pack, but I have also tried it with a 9V battery.
Does not make any difference.
Also tried changing the 5V_EN jumper, motors not moving at all.

You can get a glimpse of the motor on the image, there are no markings on it whatsover though.
7  Using Arduino / Motors, Mechanics, and Power / Fried motor contoller? on: June 30, 2012, 10:57:27 am

I have bought a dual motor contoller around a year ago but have not really used it much recently. Something like this:

Today I started playing with it.

First I have tried powering from the 5V coming from the Arduino (there's a jumper setting for it). It worked pretty fine.
(BTW I have tried with the sketch that is also on the ebay site.)

After I have tried powering from an external power source (an 12V, 500ma charger), then it stopped working (I'm pretty sure I have connect the right wires smiley). What is strange, that there are leds on the shield indicating both the power and the direction. And the power leds are fading as the Arduino PWM pin sends different signals. So it looks like at at least some parts of the shield is working.
But the motors are not moving. I also tried the board standalone (there are jumpers that can control the motors independently).
Also does not work.
Both motors can be powered from a power supply easily, so it's not the motors.

Could I have fried my motor controller? If yes, can I find out, which part? Is it easy to repair or should I get a new one (I have basic soldering skills)?

Thanks in advance! smiley
8  Using Arduino / Networking, Protocols, and Devices / Re: Arduino to Arduino communication (via BT or RF?) on: August 25, 2011, 02:16:18 am
Thanks for the very quick and detailed reply! smiley

Actually the proximity detection part need not to be very sophisticated. The only requirement is that this automatic connection should not be triggered between two devices that are far from each other. Ideally it should only be initiated if the two devices are around maximum 2-3m distance from each other. Maybe it's even easier to tweak an RF solution for this, i.e. to degrade the range.

The reason I was thinking about a BT solution that the device should ideally be able to communicate with an already BT enabled device, such as a mobile phone. And it would have been nice to be able to use the same communication channel also for Arduino-Arduino communication and for Arduino-Phone communication.

But if you say that it's easier (and cheaper, which is also an important factor) to implement this using RF, than I will go down that road. So you say that it's quite feasible to implement the above mentioned ad-hoc, master-slave, slave-master autoconnect scenario using simple RF components?
Should I buy sg like this:

And then how do I handle the part where the devices should find each other and initiate the two-way communication?
And another thing came to my mind: if there are multiple devices nearby, i.e. 5-10 devices, wouldn't there be an interference that would make such device-device communication impossible?

Thanks in advance! smiley
9  Using Arduino / Networking, Protocols, and Devices / Arduino to Arduino communication (via BT or RF?) on: August 25, 2011, 01:41:15 am
Hi everyone!

I tried to search on google and on the forums for information on my question, but so far I could not find anything that would cover exactly what I would like to achieve.

I would like to build a device the would communicate with other Arduino devives in an ad-hoc fashion. So suppose two such devives get near to each other, one of the devices (I guess the first one that detects the other one first) should initiate a connection automatically and they should be able to sync information between each other.
Maybe I don't understand the BT communication very well, but it seems to me that a BT device should either be a slave or a master at one time. But in my case, a device could be both, and any device should be able to automatically pair up with another one automatically. RF is also an option, if that's more feasible to implement. But BT is also a bit more convinient as the range is not so big (but I can also imagine somehow degrading the RF range of an RF interface).

How would this Arduino-Arduino communication be possible? Ideally the devices should be relatively small and would need to have low power consumption (well, I guess that's not easy considering that each device should be searching for others frequently).

Any ideas? smiley

Thanks & best regards,
10  Using Arduino / General Electronics / Re: Some very basic electronic component questions on: August 17, 2011, 05:35:25 am
Many many thanks for the quick and detailed replies, guys!

Also thanks about the insights (that you probably won't have the parts that you actually need). smiley

Thanks again!
11  Using Arduino / General Electronics / Some very basic electronic component questions on: August 15, 2011, 04:25:03 am
Hi everyone!

I'm an electronics newbie just getting started using an Arduino board an a couple of components.
I bought a kit on ebay that included a breadboard but also other small stuff that are required for building some devices. I know the use of most of them, but on the other hand I have no idea about the possible use / application of some others. So I would be very glad if someone just very briefly explained (or pointed me to a website where it's already discussed) what the following components are (or where they can be used). I got the names from the ebay description, maybe they are not 100% correct smiley:

- Mono capacitors
- Dynatron And Diode : BC547, BC557, 1N4007, 2N3904, 2N3906
- Optical Coupling : 4N35
- Darlington : TIP122, TIP127
- FET : IRF540
- Power Chip : L7805, LD1117 3.3V
- Chips´╝Ü74HC595, ULN2803A

The kit itself is the following:

Sorry for asking such basic questions but everyone has to go through the learning phase I guess. smiley

Thanks & best regards,
Pages: [1]