#include
/*
//arduino code for controling server that drives drawing machine
A0 is the servo
A1 is the potentiometer for fine turning height
*/
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
int minx = 0;
int trans = 0; //var for changing var from A1
int lim = 25;
void setup() {
//delay(5000);
Serial.begin(9600);
myservo.attach(9); // attaches the servo on pin 9 to the servo object is pin9 ==A0?
pos = myservo.read(); // if the servo is high, or low set servo position to 0
if (pos > 0 || pos < 0){
myservo.write(30);
}
}
void loop() {
int sensorValue = analogRead(A0); //resistors on PSU shouldnt change
Serial.println(sensorValue);
int sv = analogRead(A1);
trans = (lim - (sv/40));
if(sensorValue < 100){
myservo.write(minx);
} else{
myservo.write(trans);
}
if(sensorValue > 1000){ // its done drawing, and out of range anyways
myservo.write(30); // go back to neutral position
delay(300);
}
}