/*
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 <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27
#define LCD_COLUMNS 16
#define LCD_LINES 2
const int pote_pin = A0; // analog pin used to connect the potentiometer
const int pote_pin1 = A3;
const int analog_threshold = 500;
const int analog_threshold1 = 500;
const int RELAY_PIN = 12;
const int RELAY_PIN1 = 13;
const int RELAY_PIN2 = 11;
const int RELAY_PIN3 = 10;
const int RELAY_PIN4 = 3;
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
void setup() {
pinMode(RELAY_PIN, OUTPUT);
lcd.init();
lcd.backlight();
digitalWrite(RELAY_PIN3, HIGH);
}
void loop() {
int analogValue = analogRead(pote_pin);
int analogValue1 = analogRead(pote_pin1);
analogValue = map(analogValue, 0, 1023, 0 , 1023);
analogValue1 = map(analogValue1, 0, 1023, 0 , 1023);
if (analogValue > analog_threshold)
{
digitalWrite(RELAY_PIN, HIGH);
delay(5000); }
else if (analogValue < analog_threshold)
{
digitalWrite(RELAY_PIN1, HIGH);
delay(5000);
}
if (analogValue1 > analog_threshold1)
{
digitalWrite(RELAY_PIN2, HIGH);
delay(5000); }
else if (analogValue1 < analog_threshold1)
{
digitalWrite(RELAY_PIN3, HIGH);
delay(5000);
}
lcd.setCursor(7, 0);
lcd.print(analogValue);
lcd.setCursor(7, 1);
lcd.print(analogValue1);
}