Skip to content

Commit

Permalink
Commented
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateo-S committed Mar 18, 2019
1 parent 44eb023 commit 2711a30
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions motorTest/motorTest.ino
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#include <Servo.h>

int analogPin = A7; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read
Servo cim;
const int CIM_PIN = 9;
int analogPin = A7;
int val = 0;
Servo cim;
const int CIM_PIN = 9;
int i = 0;

void setup() {
Serial.begin(9600); // setup serial
pinMode(analogPin, INPUT);
pinMode(analogPin, INPUT); // Set A7 as an input
cim.attach(CIM_PIN);
cim.write(59);
cim.write(59); // Run motor at 1/3 speed backwards
Serial.println("Start");
delay(2000);
}
Expand All @@ -21,20 +20,20 @@ void loop() {
prev = curr;
curr = analogRead(analogPin);
Serial.println(i);
// val = analogRead(analogPin); // read the input pin
// Serial.println(val); // debug value
if(curr > 500){
i++;
delay(20);
// Serial.println(i);
}
if(i > 174){
i = 0;
cim.write(90);
Serial.println("Stop");
delay(4000);
} else {
cim.write(59);
}
//delay(200);
// val = analogRead(analogPin); // read the input pin
// Serial.println(val); // debug value
if (curr > 500) {
i++;
delay(20);
// Serial.println(i);
}
if (i > 174) {
i = 0;
cim.write(90);
Serial.println("Stop");
delay(4000);
} else {
cim.write(59);
}
//delay(200);
}

0 comments on commit 2711a30

Please sign in to comment.