Advertisement
pleasedontcode

**Pin Control** rev_01

Dec 12th, 2024
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **Pin Control**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-12-12 15:51:11
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* if i input 1 value in pin 7 then arduino pin 2 & 8 */
  21.     /* will high */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Arduino.h>
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32.  
  33. /****** PIN DEFINITIONS *****/
  34. const int inputPin = 7;  // Input pin for reading the value
  35. const int outputPin1 = 2; // First output pin
  36. const int outputPin2 = 8; // Second output pin
  37.  
  38. void setup(void)
  39. {
  40.     // Initialize the input pin as INPUT
  41.     pinMode(inputPin, INPUT);
  42.    
  43.     // Initialize the output pins as OUTPUT
  44.     pinMode(outputPin1, OUTPUT);
  45.     pinMode(outputPin2, OUTPUT);
  46. }
  47.  
  48. void loop(void)
  49. {
  50.     // Read the value from the input pin
  51.     int inputValue = digitalRead(inputPin);
  52.    
  53.     // If the input value is HIGH, set the output pins HIGH
  54.     if (inputValue == HIGH) {
  55.         digitalWrite(outputPin1, HIGH);
  56.         digitalWrite(outputPin2, HIGH);
  57.     } else {
  58.         // If the input value is LOW, set the output pins LOW
  59.         digitalWrite(outputPin1, LOW);
  60.         digitalWrite(outputPin2, LOW);
  61.     }
  62. }
  63.  
  64. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement