Quick question. I am using a 50k pot to adjust the speed of a fan motor for a trade show display. I am using a servo style control to run high amp fans. My question is, when my pot is at 0 or open sometimes there is a bit of resistance there still making my amp readout to show 2-4. I would like the display to read 0 when the pot should be at open, then display amp draw as the pot is turned as the fans pick up speed.
/*
Controlling a servo position using a potentiometer (variable resistor)
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
modified on 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Knob
*/
#include <Adafruit_LiquidCrystal.h>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
Adafruit_LiquidCrystal lcd(0);
/***************************************/
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int amp;
/***************************************/
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
lcd.begin(20 , 4);
lcd.setBacklight(HIGH);
lcd.print(" Derale Performance");
Serial.begin(9600);
}
/***************************************/
void loop() {
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 92, 170); // scale it to use it with the servo (value between 0 and 180)
amp = val-92;
lcd.setCursor(0,2);
lcd.print("Amp Draw ");
lcd.print(amp/2);
lcd.setCursor(0,3);
lcd.print("Temperature ");
lcd.print(val+40);
myservo.write(val); // sets the servo position according to the scaled value
delay(150); // waits for the servo to get there
}