Hi,
I wonder if anyone is able to help me. A friend of mine wrote a code for me that runs a looped sequence of different on/off times that i have been using to run a solenoid which powers a mouth for a model that i have made. In this one i have it set to a quick burst of on/off, but in others i have changed the on/off sequence to be more varied.
Essentially, what i am now trying to do is run three separate solenoids (to run three mouthes) at the same time from the one arduino. I have been looking at tutorials on the internet but everything seems to be using a delay and, from what i can make out from my very limited knowledge of writing code is that this means that when one of the solenoids is on, the other two are off.
What i am wanting is for three to run independently from one another, at the same time.
Unfortunately, my friend who helps me on these things is away for some time so i am floundering in the dark here. What i want to know is a) is this something that is possible to do off of one arduino or does it not work like this? and b) is it possible to do this by changing the existing code that i have already got or will in need to be totally re-written in order to function like this?
Best
J
// the setup function runs once when you press reset or power the board
int triggerTime[] = {
340,560,200,500,430,1100,980,160,1500,320,720,200,100,340,100}; // length of delay in milliseconds
int mouthPin1 = 8;
int openTime[] = {
700,1100,340,1500,780,400,340,700,230,800,190,340,1030,600,900}; // length of delay in milliseconds
int index=0;
void setup() {
Serial.begin(9600);
pinMode(mouthPin1, OUTPUT);
}
void loop() {
for (int i = 0; i < (sizeof(triggerTime)/sizeof(int)) - 1; i++) {
delay(triggerTime[i]);
digitalWrite(mouthPin1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(openTime[i]); // wait for a second
digitalWrite(mouthPin1, LOW); // turn the LED off by making the voltage LOW
}
// after running through the arrays, the program will wait between 5 seconds
int CoolingTime = 5000;
delay(CoolingTime);
}