analog value to control delay value???

hey guys/girls, I'm starting a project that uses two pots to control delay/millis and one resistor block to control the count of how many times 1 & 2 happen

  1. digitalWrite, HIGH for X time
  2. digitalWrite, LOW for X time
  3. count of HIGH and Low

I wanted to do something with using the analog value (0-1023) to control amount of delay for 1&2

(analogRead value * 10 = delay)

For the resistor block / selector switch to control the count of 1 &2 combined in increments of 2,4,6,8,10

Is there a library for this or can some guide me a little?

google wasn't a lot of help for what I searched...

Thanks guys/girls

Not difficult - can you post your code?

Allan

haven't started to code it yet.. I was just asking if there was something available already.

i'll try to post a code in a couple of days if I cant find anything.

Coding is still new to me and it helps me a lot if I can see an example to understand how its done instead of coming up with something from nothing...

I recall having seen example code of this - may be included in your IDE even.

Actually you got half of the control code up there already. Next have a look at "Blink Without Delay" on how to trigger your output at your required interval without blocking, so you can do the same for two outputs independently.

how would one go about attaching time to the value. I would prefer to use delay because the time that the relay is being operated will turn the sensor value to low.

also I decided to go with two on/off switches to control the count.

(A==LOW & B==LOW)=4 count
(A==HIGH & B==LOW)= 8 count

pretty much a combination of on and off to go in counts of 4,8,12,16

const int relay = 2; // digitalWrite to relay coil
const int sensor = 7; // on/off sensor
int onTime = A0; // pot to determine digitalWrite HIGH
int offTime = A1; // pot to determin digitalWrite LOW
const int countA = 10; // on/off switch A
const int countB = 11; // on/off switch B
long delayValueH; // delay high value
long delayValueL; // delay low value



void setup() {
  pinMode(relay,OUTPUT);
  pinMode(sensor,INPUT);
  pinMode(countA,INPUT);
  pinMode(countB,INPUT);
  delayValueH = analogRead(onTime);
  delayValueL = analogRead(offTime);
  
}

void loop() {

    delayValueH = delay(onTime * 10);
    delayValueL = delay(offTime *10);

I think I need more help on how to set up the count portion.
I've never done a count.

would this be how to write the delay?

delay(onTime * 10);
delay(offTime * 10);

Look carefully is onTome the number you read with analogRead or is it a very poorly named variable actually holding a pin number. Look where you assigned a value to it, what value did you give it? What variable did you put the result of analogRead into?

??? like this

delay(delayValueH * 10)
delay (delayValurL * 10)

That makes a lot more sense. Don’t forget your ‘;’

thank you sir. I will post my "finished" code ASAP.