Pages: [1]   Go Down
Author Topic: Simple switching circuit to pulse a motor?  (Read 317 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So essentially what I am doing here is powering a small motor via a "digital" switch. What I would like to happen is that once the motor is switched on the motor is on for 7 seconds then off for 7 seconds continuously forever. If the switch is pressed then the motor and the cycle stops.

If the switch is pressed again then the whole thing kicks off again.

I am sure this should be really quite straight forward ? any help appreciated. I am not too sure how to interrupt the delay function?

int QTCPin = 12;      // select the input pin for the switch
int MotPin = 11; // select the outpin for the Motor circuit
int QTCval ;      // variable to store the value coming from the switch

void setup() {
  pinMode(QTCPin, INPUT);  // declare the Switch as an INPUT
  pinMode(MotPin, OUTPUT); //declare the Motpin as an OUTPUT

void loop() {

   QTCval = digitalRead(QTCPin);    // read the value from the PIN
 if(QTCval== HIGH)  
          {digitalWrite(MotPin, HIGH);
          delay (1000*7);
          digitalWrite(MotPin, LOW);
           delay (1000*7);
          digitalWrite(MotPin, LOW);  


Pages: [1]   Go Up
Jump to: