Can i feed arduino some voltage trough analog in so it reads it as high or low?

I have problem with program because i need to program servos to go back and forth without delay function and i can't find solution for it so i thought that solution would be capacitor timer over resistor into the arduino so it can read high or low and i can use it without delay. Will that work?

Why can't you use a delay based on the millis() function?

.

i tried servos behave very weirdly. I would like to see your solution if you can code it fast. I am a beginner, and I used for loops if you can write some code down so i can analyze it and use it, i am like a sponge now i want all the knowledge i can get.

You should be showing us your current sketch.

There is an example called Blink Without Delay in the IDE.

This example demonstrates some ways to use this method:

//Simple BWD BlinkWithoutDelay examples
//
//Timer variables used
unsigned long currentMillis;
unsigned long pin13Millis;
unsigned long pin12Millis;
unsigned long SwitchMillis;
 
//if these are not changed in the sketch, they can be const
unsigned long debounceMillis = 50UL;  //50ms
unsigned long ledOnTime      = 500UL; //500ms seconds
 
byte lastSwitchState = HIGH;
byte buttonState     = HIGH;
 
//enable/disable flags
boolean flag13 = true;
boolean flag12 = false;
 
const byte Switch = 2; //pushed = LOW
 
//**********************************************************************
 
void setup()
{
  Serial.begin(9600);
 
  digitalWrite(13,LOW);
  pinMode(13, OUTPUT);
  
  digitalWrite(12,LOW);
  pinMode(12, OUTPUT);
 
  pinMode(Switch, INPUT_PULLUP); //pushed = LOW
 
} //  >>>>>>>>>>>>>> E N D  O F  s e t u p ( ) <<<<<<<<<<<<<<<<<
 
void loop()
{
  //save the current time
  currentMillis = millis();
 
  //*************************************
  //Heartbeat LED
  //Toggle LED on and off. Helps show if there is blocking code
  if (flag13 == true && currentMillis - pin13Millis >= ledOnTime)
  {
    pin13Millis = millis();            //re-initialize Timer
    digitalWrite(13,!digitalRead(13)); //toggle LED condition
  }
 
  //*************************************
  if (flag12 == true && currentMillis - pin12Millis >= 5*1000UL)
  {
    //Turn off pin 12
    digitalWrite(12,LOW); //Turn off LED
    flag12 = false;       //disable timing
  }
 
  //*************************************
  //is it time to check the switches?
  if (currentMillis - SwitchMillis >= debounceMillis)
  {
    //code here runs every debounceMillis ms
    SwitchMillis = millis(); //re-initilize Timer
    //go and check the switches
    checkSwitches();   
  }
 
  //*********************************
  //put other non-blocking stuff here
  //*********************************
 
} //  >>>>>>>>>>>>>> E N D  O F  l o o p ( ) <<<<<<<<<<<<<<<<<
 
 
//======================================================================
//                      F U N C T I O N S
//======================================================================
 
 
//****************** c h e c k S w i t c h e s ( ) *********************
//switches are checked every debounceValue milli seconds
//no minimum switch press time is validated with this code (i.e. No glitch filter)
void checkSwitches() 
{
  //re-usable for all the switches 
  boolean thisState;   
 
  //check if this switch has changed state
  thisState = digitalRead(Switch);
  if (thisState != lastSwitchState)
  { 
    //update the switch state
    lastSwitchState = thisState; 
 
    //this switch position has changed so do some stuff
    //"LOW condition code"
    //has switch gone from HIGH to LOW?
    if(thisState == LOW)                         
    {
      //Do some LOW switch stuff here 
      flag12 = true;          //allow timing
      digitalWrite(12, HIGH); //turn on LED
      pin12Millis = millis(); //initialize Timer
    }
 
  } //END of Switch code
 
  //***************************************** 
  // similar code for other switches goes here
  //***************************************** 
 
} //END of checkSwitches()
 
//**********************************************************************
 
//======================================================================
//                      E N D  O F  C O D E
//======================================================================

I need code without delay that would run servos not blinker, i know blinker code alredy.

What you need is in your head.

Show us your sketch, or don’t.

Always show us your current compete sketch.
Use CTRL T to format the sketch.
Please use code tags.
Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]

.

@Mixailo, read through Robin2's several things at the same time. It has a servo sweep included in it. Without using delay.

i cant show it to you because it absolutely don’t work with delay it is:
#include <Servo.h>
Servo servo0;
int pos0 = 0;
void setup()
{
servo1.attach(6);
}
for(pos0 = 0; pos0 , 180; pos0 += 1)
{
servo0.write(pos0);
delay(10);
}
for(pos0 = 180; pos0>=1; pos0-=1)
{
servo0.write(pos0);
delay(10);
}
}

and i should fit in analogWrite with it’s own timing

@vinceherman thanks.