SHARE
TWEET

pt2262

shamrock_007 Jul 4th, 2016 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const int inputA = 2;       // Input A
  2. const int inputB = 3;       // Input B
  3. const int inputC = 8;       // Input C
  4. const int inputD = 9;       // Input D
  5. const int outputW = 4;       // Output W
  6. const int outputX = 5;       // Output X
  7. const int outputY = 6;       // Output Y
  8. const int outputZ = 11;       // Output Z
  9.  
  10. // Use variables for values that will change:
  11. int readState = 0;           // Variable for reading the input status
  12.  
  13. void setup() {
  14.  
  15.   // Setup inputs:
  16.   pinMode(inputA, INPUT);
  17.   pinMode(inputB, INPUT);
  18.   pinMode(inputC, INPUT);
  19.   pinMode(inputD, INPUT);
  20.  
  21.   // Setup outputs:
  22.   pinMode(outputW, OUTPUT);
  23.   pinMode(outputX, OUTPUT);
  24.   pinMode(outputY, OUTPUT);
  25.   pinMode(outputZ, OUTPUT);
  26. }
  27.  
  28. void loop() {
  29.   // Read the state of the first input value:
  30.   readState = digitalRead(inputA);
  31.  
  32.   if (readState == HIGH) {
  33.     // turn LED on:
  34.     digitalWrite(outputW, HIGH);
  35.   }
  36.   else {
  37.     // turn LED off:
  38.     digitalWrite(outputW, LOW);
  39.   }
  40.  
  41.   // Read the state of the second input value:
  42.   readState = digitalRead(inputB);
  43.  
  44.   if (readState == HIGH) {
  45.     // turn LED on:
  46.     digitalWrite(outputX, HIGH);
  47.   }
  48.   else {
  49.     // turn LED off:
  50.     digitalWrite(outputX, LOW);
  51.   }
  52.  
  53.   // Read the state of the third input value:
  54.   readState = digitalRead(inputC);
  55.  
  56.   if (readState == HIGH) {
  57.     // turn LED on:
  58.     digitalWrite(outputY, HIGH);
  59.   }
  60.   else {
  61.     // turn LED off:
  62.     digitalWrite(outputY, LOW);
  63.   }
  64.  
  65.   // Read the state of the fourth input value:
  66.   readState = digitalRead(inputD);
  67.  
  68.   if (readState == HIGH) {
  69.     // turn LED on:
  70.     digitalWrite(outputZ, HIGH);
  71.   }
  72.   else {
  73.     // turn LED off:
  74.     digitalWrite(outputZ, LOW);
  75.   }
  76. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top