Hi,
I'm using an Arduino Uno board along with a Parallax Inc Servo Motor, 6 → 8.4 V, 180 rpm.
I am trying to use this to move a piece of paper to change an intensity value on a camera or photoresistor.
I am hoping to make it rotate fast at first until it finds the minimum then pause. After this it should check the intensity again and then rotate backwards slowly until it finds it (due to overshooting it before). Then repeating this in the opposite direction slower and stopping once more at the minimum value.
I was wondering how I would do this as I previously was using several if statements and delays.
#include<Servo.h>
Servo halfWave; //Servo Motor name
const int servPin1 = 9; //Pin the Servo is attached to (See Below)
void setup() {
Serial.begin(9600);
pinMode(servPin1, OUTPUT);
halfWave.attach(9);
}
void loop() {
Serial.println("Ready"); //Signal to LabVIEW
while(Serial.available() == 0);
String intensity = Serial.readString();
int intenVal = intensity.toInt(); //Need the integer value of the Intensity
do {
halfWave.write(180); //If the intensity isn't right then it rotates the servo continuously until it is low
enough
}while(intenVal != 200);
}
This is currently what I have to find the minimum the first time, but now I am wondering how it can check it again after this and then do another "do" loop but at a slower speed.