Hello everyone, i am new to arduino and this forum... i need some help for my project and sorry for my bad english.
i used solenoid push - pull (12V/2A) , and pressure sensor.
main goal
1.read the pressure and display on LCD.
2.controlling the push power of the solenoid according to the value from the sensor
So my idea to control the push power is using time... for example
solenoid will on/HIGH = 10ms, then off/LOW=990ms ( less power )
or on/HIGH=100ms, then off/LOW=900 ms (Full Power)
and i know i can't use delay for multitasking on arduino, so i already used milis(); function, and i made void function for the pressure code.
the problem is
solenoid worked fine when i did not call the pressure function, it moves according to the time i set.
but when i called the pressure function, the solenoid just do the normal HIGH and LOW, how do i solve this?
here is the example of my code
//I set the time here for control the push power
.
.
unsigned long tOn = 10;
unsigned long tOff = 750;
.
.
.
void loop() {
//PressureSensor(); this is the function that i made for the sensor i used
//this the milis function for the solenoid
current milis = millis();
if((statusSolenoid == HIGH) && (currentmilis - prevmilis >= tOn)) {
statusSolenoid = LOW;
prevmilis = currentmilis;
digitalWrite(solenoid, statusSolenoid);
} else if ((statusSolenoid == LOW) && (currentmilis - prevmilis >= tOff)) {
statusSolenoid = HIGH;
prevmilis = currentmilis;
digitalWrite(solenoid, statusSolenoid);
}
}
what that causing my problem?