int main(void)
{
DDRC = DDRC | (1<<2);
DDRC = DDRC | (1<<3);
while (1)
{
//openSolenoidValves(100,60);
//startStepperMotor();
}
void openSolenoidValves(double air, double oxygen) {
PORTC = PORTC | (1<<2); //open oxygen(normally closed valve)
PORTC = PORTC & (~(1<<3)); //open air (normally open valve)
_delay_ms(oxygen);
PORTC = PORTC & (~(1<<2));//close oxygen
_delay_ms(air-oxygen);
PORTC = PORTC | (1<<3);//close air
_delay_ms(air);
}
void startStepperMotor(){
//this function also has delays
}
I want to start both openSolenoidValve function and startStepperMotor function same time.But both functions have delays. Is there any method to do that? (MicroController-Atmega32)
This millis() function help me to solve my problem.
Just like the millis() function in Arduino, this function returns the time in milliseconds since the program started.
As Developers' details, This function has only been tested on the atmega328p but may work on many other AVRs as well.
Implementing this function is easy - take a look at the example: