Components and supplies
Enclosure for Arduino Uno
Solenoid Valve, 2 Way
Rotary potentiometer (generic)
Tactile Switch, Top Actuated
Power Relay, SPDT
Project description
Code
untitled
arduino
1/* 2 3POT1 >> DELAY of SIZE of DROP1 4POT2 >> DELAY for DROP2 5POT3 >> DELAY of SIZE of DROP2 6POT4 >> DELAY for CAMERA TRIGER from END OF D1 7 8*/ 9 10 11 12int potPin1 = 0; // select the input pin for the potentiometer 13int potPin2 = 1; // select the input pin for the potentiometer 14int potPin3 = 2; // select the input pin for the potentiometer 15int potPin4 = 3; // select the input pin for the potentiometer 16int ValvePin = 8; // select the pin for the Valve 17int CameraPin = 9; // to trigger camera 18int TriggerPin = 2; // Swith trigger 19 20int LEDRed = 6; 21int LEDGreen = 7; 22 23int d1, d2, d3, d4; // Delay values of each POT's 24int d1m, d2m, d3m, d4m; //Max delay corresponding full scale of POT (1023) 25 26float pm = 1023.0; 27 28 29 30void setup() { 31 32 Serial.begin(9600); 33 34 35 //Setting Pin Modes 36 pinMode(potPin1, INPUT); // declare the PotPin as an INPUT 37 pinMode(potPin2, INPUT); // declare the PotPin as an INPUT 38 pinMode(potPin3, INPUT); // declare the PotPin as an INPUT 39 pinMode(potPin4, INPUT); // declare the PotPin as an INPUT 40 pinMode(ValvePin, OUTPUT); // declare the ValvePin as an OUTPUT 41 pinMode(CameraPin, OUTPUT); // declare the CameraPin as an OUTPUT 42 pinMode(TriggerPin, INPUT_PULLUP); // For the Switch 43 44 45 pinMode(LEDRed, OUTPUT); // declare LED Red 46 pinMode(LEDGreen, OUTPUT); // declare LED Green 47 48 49 50 // intializing..... 51 52 // Max of each Pot 53 d1m = 150; 54 d2m = 500; 55 d3m = 150; 56 d4m = 500; 57 58 // Set valve, camera, LED pins low 59 digitalWrite(ValvePin, HIGH); 60 digitalWrite(CameraPin, HIGH); 61 62 LED_Set(0); 63 64} 65 66void loop() { 67 68 69 if ( digitalRead(TriggerPin) == LOW ) { 70 71 72 // turn LED RED 73 LED_Set(-1); 74 delay(1000); 75 76 // Read Pot positions and set delays 77 d1 = (analogRead(potPin1) / pm) * d1m ; 78 d2 = (analogRead(potPin2) / pm) * d2m ; 79 d3 = (analogRead(potPin3) / pm) * d3m ; 80 d4 = (analogRead(potPin4) / pm) * d4m ; 81 d4 = d4 - d2 - d3; 82 83 84 85 //STARTING LOOP **************************** 86 87 //first drop 88 LED_Set(1); // turn LED GREEN 89 digitalWrite(ValvePin, LOW); // turn the Valve on 90 delay(d1); 91 digitalWrite(ValvePin, HIGH); // turn the Valve off 92 LED_Set(-1); // turn LED RED 93 // first drop complete 94 95 96 //waiting for GAP for Drop 2 97 delay(d2); 98 99 100 //second drop 101 102 LED_Set(1); // turn LED GREEN 103 digitalWrite(ValvePin, LOW); // turn the Valve on 104 delay(d3); 105 digitalWrite(ValvePin, HIGH); // turn the Valve off 106 LED_Set(-1); // turn LED RED 107 //second drop complete 108 109 110 //waiting for camera trigerring 111 if (d4 >=0) { 112 delay(d4); 113 114 //trigger camera 115 LED_Set(1); // turn LED GREEN 116 digitalWrite(CameraPin, LOW); // turn the Valve on 117 delay(200); 118 digitalWrite(CameraPin, HIGH); // turn the Valve off 119 delay(100); // for seeing LED 120 LED_Set(-1); // turn LED RED 121 122 } 123 124 125 // turn OFF Switch LED 126 delay(100); 127 LED_Set(0); // turn LED OFF 128 129 } 130 131 132 133 134} 135 136 137void LED_Set(int LEDColor) { 138 139 // LEDColor : -1 > RED | 0 > OFF | 1 > GREEN 140 141 Serial.println(LEDColor); 142 143 if (LEDColor == -1) { 144 digitalWrite(LEDGreen, LOW); 145 digitalWrite(LEDRed, HIGH); 146 } else if (LEDColor == 0) { 147 digitalWrite(LEDRed, LOW); 148 digitalWrite(LEDGreen, LOW); 149 } else if (LEDColor == 1) { 150 digitalWrite(LEDRed, LOW); 151 digitalWrite(LEDGreen, HIGH); 152 } 153 154 155 156} 157 158
untitled
arduino
1/* 2 3POT1 >> DELAY of SIZE of DROP1 4POT2 >> DELAY for DROP2 5POT3 >> DELAY of SIZE of DROP2 6POT4 >> DELAY for CAMERA TRIGER from END OF D1 7 8*/ 9 10 11 12int potPin1 = 0; // select the input pin for the potentiometer 13int potPin2 = 1; // select the input pin for the potentiometer 14int potPin3 = 2; // select the input pin for the potentiometer 15int potPin4 = 3; // select the input pin for the potentiometer 16int ValvePin = 8; // select the pin for the Valve 17int CameraPin = 9; // to trigger camera 18int TriggerPin = 2; // Swith trigger 19 20int LEDRed = 6; 21int LEDGreen = 7; 22 23int d1, d2, d3, d4; // Delay values of each POT's 24int d1m, d2m, d3m, d4m; //Max delay corresponding full scale of POT (1023) 25 26float pm = 1023.0; 27 28 29 30void setup() { 31 32 Serial.begin(9600); 33 34 35 //Setting Pin Modes 36 pinMode(potPin1, INPUT); // declare the PotPin as an INPUT 37 pinMode(potPin2, INPUT); // declare the PotPin as an INPUT 38 pinMode(potPin3, INPUT); // declare the PotPin as an INPUT 39 pinMode(potPin4, INPUT); // declare the PotPin as an INPUT 40 pinMode(ValvePin, OUTPUT); // declare the ValvePin as an OUTPUT 41 pinMode(CameraPin, OUTPUT); // declare the CameraPin as an OUTPUT 42 pinMode(TriggerPin, INPUT_PULLUP); // For the Switch 43 44 45 pinMode(LEDRed, OUTPUT); // declare LED Red 46 pinMode(LEDGreen, OUTPUT); // declare LED Green 47 48 49 50 // intializing..... 51 52 // Max of each Pot 53 d1m = 150; 54 d2m = 500; 55 d3m = 150; 56 d4m = 500; 57 58 // Set valve, camera, LED pins low 59 digitalWrite(ValvePin, HIGH); 60 digitalWrite(CameraPin, HIGH); 61 62 LED_Set(0); 63 64} 65 66void loop() { 67 68 69 if ( digitalRead(TriggerPin) == LOW ) { 70 71 72 // turn LED RED 73 LED_Set(-1); 74 delay(1000); 75 76 // Read Pot positions and set delays 77 d1 = (analogRead(potPin1) / pm) * d1m ; 78 d2 = (analogRead(potPin2) / pm) * d2m ; 79 d3 = (analogRead(potPin3) / pm) * d3m ; 80 d4 = (analogRead(potPin4) / pm) * d4m ; 81 d4 = d4 - d2 - d3; 82 83 84 85 //STARTING LOOP **************************** 86 87 //first drop 88 LED_Set(1); // turn LED GREEN 89 digitalWrite(ValvePin, LOW); // turn the Valve on 90 delay(d1); 91 digitalWrite(ValvePin, HIGH); // turn the Valve off 92 LED_Set(-1); // turn LED RED 93 // first drop complete 94 95 96 //waiting for GAP for Drop 2 97 delay(d2); 98 99 100 //second drop 101 102 LED_Set(1); // turn LED GREEN 103 digitalWrite(ValvePin, LOW); // turn the Valve on 104 delay(d3); 105 digitalWrite(ValvePin, HIGH); // turn the Valve off 106 LED_Set(-1); // turn LED RED 107 //second drop complete 108 109 110 //waiting for camera trigerring 111 if (d4 >=0) { 112 delay(d4); 113 114 //trigger camera 115 LED_Set(1); // turn LED GREEN 116 digitalWrite(CameraPin, LOW); // turn the Valve on 117 delay(200); 118 digitalWrite(CameraPin, HIGH); // turn the Valve off 119 delay(100); // for seeing LED 120 LED_Set(-1); // turn LED RED 121 122 } 123 124 125 // turn OFF Switch LED 126 delay(100); 127 LED_Set(0); // turn LED OFF 128 129 } 130 131 132 133 134} 135 136 137void LED_Set(int LEDColor) { 138 139 // LEDColor : -1 > RED | 0 > OFF | 1 > GREEN 140 141 Serial.println(LEDColor); 142 143 if (LEDColor == -1) { 144 digitalWrite(LEDGreen, LOW); 145 digitalWrite(LEDRed, HIGH); 146 } else if (LEDColor == 0) { 147 digitalWrite(LEDRed, LOW); 148 digitalWrite(LEDGreen, LOW); 149 } else if (LEDColor == 1) { 150 digitalWrite(LEDRed, LOW); 151 digitalWrite(LEDGreen, HIGH); 152 } 153 154 155 156} 157 158
untitled
arduino
1/* 2 3POT1 >> DELAY of SIZE of DROP1 4POT2 >> DELAY for DROP2 5POT3 6 >> DELAY of SIZE of DROP2 7POT4 >> DELAY for CAMERA TRIGER from END OF D1 8 9*/ 10 11 12 13int 14 potPin1 = 0; // select the input pin for the potentiometer 15int potPin2 = 1; 16 // select the input pin for the potentiometer 17int potPin3 = 2; // select 18 the input pin for the potentiometer 19int potPin4 = 3; // select the input pin 20 for the potentiometer 21int ValvePin = 8; // select the pin for the Valve 22int 23 CameraPin = 9; // to trigger camera 24int TriggerPin = 2; // Swith trigger 25 26int 27 LEDRed = 6; 28int LEDGreen = 7; 29 30int d1, d2, d3, d4; // Delay values of 31 each POT's 32int d1m, d2m, d3m, d4m; //Max delay corresponding full scale of 33 POT (1023) 34 35float pm = 1023.0; 36 37 38 39void setup() { 40 41 Serial.begin(9600); 42 43 44 45 //Setting Pin Modes 46 pinMode(potPin1, INPUT); // declare the 47 PotPin as an INPUT 48 pinMode(potPin2, INPUT); // declare the PotPin as an INPUT 49 50 pinMode(potPin3, INPUT); // declare the PotPin as an INPUT 51 pinMode(potPin4, 52 INPUT); // declare the PotPin as an INPUT 53 pinMode(ValvePin, OUTPUT); // declare 54 the ValvePin as an OUTPUT 55 pinMode(CameraPin, OUTPUT); // declare the CameraPin 56 as an OUTPUT 57 pinMode(TriggerPin, INPUT_PULLUP); // For the Switch 58 59 60 61 pinMode(LEDRed, OUTPUT); // declare LED Red 62 pinMode(LEDGreen, OUTPUT); 63 // declare LED Green 64 65 66 67 // intializing..... 68 69 // 70 Max of each Pot 71 d1m = 150; 72 d2m = 500; 73 d3m = 150; 74 d4m = 500; 75 76 77 // Set valve, camera, LED pins low 78 digitalWrite(ValvePin, HIGH); 79 80 digitalWrite(CameraPin, HIGH); 81 82 LED_Set(0); 83 84} 85 86void loop() 87 { 88 89 90 if ( digitalRead(TriggerPin) == LOW ) { 91 92 93 // 94 turn LED RED 95 LED_Set(-1); 96 delay(1000); 97 98 // Read Pot 99 positions and set delays 100 d1 = (analogRead(potPin1) / pm) * d1m ; 101 d2 102 = (analogRead(potPin2) / pm) * d2m ; 103 d3 = (analogRead(potPin3) / pm) * d3m 104 ; 105 d4 = (analogRead(potPin4) / pm) * d4m ; 106 d4 = d4 - d2 - d3; 107 108 109 110 111 //STARTING LOOP **************************** 112 113 //first 114 drop 115 LED_Set(1); // turn LED GREEN 116 digitalWrite(ValvePin, 117 LOW); // turn the Valve on 118 delay(d1); 119 digitalWrite(ValvePin, HIGH); 120 // turn the Valve off 121 LED_Set(-1); // turn LED RED 122 // first drop 123 complete 124 125 126 //waiting for GAP for Drop 2 127 delay(d2); 128 129 130 131 //second drop 132 133 LED_Set(1); // turn LED GREEN 134 135 digitalWrite(ValvePin, LOW); // turn the Valve on 136 delay(d3); 137 138 digitalWrite(ValvePin, HIGH); // turn the Valve off 139 LED_Set(-1); // 140 turn LED RED 141 //second drop complete 142 143 144 //waiting for 145 camera trigerring 146 if (d4 >=0) { 147 delay(d4); 148 149 //trigger 150 camera 151 LED_Set(1); // turn LED GREEN 152 digitalWrite(CameraPin, 153 LOW); // turn the Valve on 154 delay(200); 155 digitalWrite(CameraPin, 156 HIGH); // turn the Valve off 157 delay(100); // for 158 seeing LED 159 LED_Set(-1); // turn LED RED 160 161 } 162 163 164 165 // turn OFF Switch LED 166 delay(100); 167 LED_Set(0); // turn 168 LED OFF 169 170 } 171 172 173 174 175} 176 177 178void LED_Set(int 179 LEDColor) { 180 181 // LEDColor : -1 > RED | 0 > OFF | 1 > GREEN 182 183 Serial.println(LEDColor); 184 185 186 if (LEDColor == -1) { 187 digitalWrite(LEDGreen, LOW); 188 digitalWrite(LEDRed, 189 HIGH); 190 } else if (LEDColor == 0) { 191 digitalWrite(LEDRed, LOW); 192 193 digitalWrite(LEDGreen, LOW); 194 } else if (LEDColor == 1) { 195 digitalWrite(LEDRed, 196 LOW); 197 digitalWrite(LEDGreen, HIGH); 198 } 199 200 201 202} 203 204
Downloadable files
Schematic
Schematic
Schematic
Schematic
Setup
Setup
Comments
Only logged in users can leave comments