Hi,
I'd like to use one variable for two seconds then another to create a third.
output = pot for 2 seconds then,
output = pot / 2 going forward.
If possible,,,How?
Thanks,
int Pot; //Pot reading
int PotD; //Pot reading divided by 2
int Output; // value that uses "Pot" for two seconds then uses "PotD"
int APOTI;
#define APOTI A1
void setup() {
pinMode(APOTI, INPUT);
Serial.begin(9600);
}
void loop() {
int Pot = analogRead(1);
(PotD = Pot / 2);
delay(90);
Serial.print("Pot ");
Serial.print(Pot);
Serial.print("\t");
Serial.print("PotD ");
Serial.print(PotD);
Serial.print("\t");
Serial.print("Output ");
Serial.print(Output);
Serial.println("\t");
}
unsigned long previousMillis = 0;
const long interval = 3000;
int Pot; //Pot reading
int PotD; //Pot reading divided by 2
int Output; // value that uses "Pot" for two seconds then uses "PotD"
int APOTI;
#define APOTI A1
void setup() {
pinMode(APOTI, INPUT);
Serial.begin(9600);
}
void loop() {
int Pot = analogRead(1);
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (Output = Pot) {
} else {
Output = PotD;
}
(PotD = Pot / 2);
delay(90);
Serial.print("Pot ");
Serial.print(Pot);
Serial.print("\t");
Serial.print("PotD ");
Serial.print(PotD);
Serial.print("\t");
Serial.print("Output ");
Serial.print(Output);
Serial.println("\t");
}
}
Hi gcjr,
That works as well, but I'd like it to reset when "pot" is changed.
pot 402 output 201
pot 341 output 341
pot 341 output 341
pot 341 output 170
"pot" isn't a potentiometer output but changes like " 250, 200, 300, 325, 275" at various time intervals.
Hi Delta_G,
My apologies on omitting that last parameter of my objective.
I try to keep things simple and concise for as not to get sidetracked.
GC's solution proved to be the resolution, although I don't need the "halving" on the decrease side it still works well for me.
Thanks to you and GC for taking the time to help me out.
I learn a little bit every time.