Motor shield Play/Pause function

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
coX
 
Posts: 4
Joined: Wed Sep 21, 2011 10:17 am

Motor shield Play/Pause function

Post by coX »

I'm using your Motor shield to control two DC motor; on the arduino I've implemented a function which allow to play/pause motor. To do it I've used the attachInterrupt function on pin 2 but it doesn't work; I've tested it without the shield and it works. How can I implement a function that allow me to play/pause the execution of the program?
Tnks!

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor shield Play/Pause function

Post by adafruit_support_bill »

The shield does not use pin 2. What else is your code doing?

coX
 
Posts: 4
Joined: Wed Sep 21, 2011 10:17 am

Re: Motor shield Play/Pause function

Post by coX »

The code call the Interrupt function already when the button isn't pressed. May be I've solved the problem with a second connection to pin 2: i've connected it to ground using a 10k resistor and it seems working. It is the right solution?

The function where I stop the code is:

void piatto(unsigned long x)
{ unsigned long t = millis();
int stato = 0;
int save = 0;
Serial.println(x);
while(((millis()-t))<x)
{ if(state==1)
{ Serial.println("Tempo inizio pausa");
Serial.println(millis());
x = x + t - millis();
while(state==1)
{ Serial.println("Pause");
}
t = millis();
Serial.println("Tempo fine pausa");
Serial.println(t);
}
Serial.println(settings.v);
}
}

And the function called from interrupt is:

void pause()
{ state = 1-state;
delay(100);
}

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor shield Play/Pause function

Post by adafruit_support_bill »

i've connected it to ground using a 10k resistor and it seems working. It is the right solution?
That's the right solution. A pull-down resistor keeps the input from 'floating' and giving you false interrupts. :)

coX
 
Posts: 4
Joined: Wed Sep 21, 2011 10:17 am

Re: Motor shield Play/Pause function

Post by coX »

Thanks! :D

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”