2024-06-03
This commit is contained in:
		
							
								
								
									
										50
									
								
								_-Review/arduino.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								_-Review/arduino.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,50 @@ | ||||
| --- | ||||
| type: "topic" | ||||
| created: "2024-01-06T01:25:36.094Z" | ||||
| updated: "2024-01-06T01:25:36.094Z" | ||||
| --- | ||||
|  | ||||
| # Arduino | ||||
|  | ||||
| ```c++ Sprinklers | ||||
| const int last = 8; | ||||
| const int first = 5; | ||||
| const int minutes = 1; | ||||
|  | ||||
| int pin; | ||||
| int counter = 0; | ||||
|  | ||||
| void setup() { | ||||
|   pinMode(first, OUTPUT); | ||||
|   pinMode(first + 1, OUTPUT); | ||||
|   pinMode(first + 2, OUTPUT); | ||||
|   pinMode(first + 3, OUTPUT); | ||||
|   pinMode(LED_BUILTIN, OUTPUT); | ||||
|   digitalWrite(first, HIGH); | ||||
|   digitalWrite(first + 1, HIGH); | ||||
|   digitalWrite(first + 2, HIGH); | ||||
|   digitalWrite(first + 3, HIGH); | ||||
|   digitalWrite(LED_BUILTIN, LOW); | ||||
| } | ||||
|  | ||||
| void loop() { | ||||
|   pin = first + counter; | ||||
|   digitalWrite(pin, LOW); | ||||
|   if(counter == 0) | ||||
|     delay(minutes * 60 * 1000UL); | ||||
|   else if(counter == 1) | ||||
|     delay(minutes * 30 * 1000UL); | ||||
|   else if(counter == 2) | ||||
|     delay(minutes * 60 * 1000UL); | ||||
|   else if(counter == 3) | ||||
|     delay(minutes * 60 * 1000UL); | ||||
|   else | ||||
|     delay(minutes * 1 * 1000UL); | ||||
|   digitalWrite(pin, HIGH); | ||||
|   counter += 1; | ||||
|   if (pin >= last) | ||||
|   { | ||||
|     counter = 0; | ||||
|   } | ||||
| } | ||||
| ``` | ||||
		Reference in New Issue
	
	Block a user