Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int inputA = 2; // Input A
- const int inputB = 3; // Input B
- const int inputC = 8; // Input C
- const int inputD = 9; // Input D
- const int outputW = 4; // Output W
- const int outputX = 5; // Output X
- const int outputY = 6; // Output Y
- const int outputZ = 11; // Output Z
- // Use variables for values that will change:
- int readState = 0; // Variable for reading the input status
- void setup() {
- // Setup inputs:
- pinMode(inputA, INPUT);
- pinMode(inputB, INPUT);
- pinMode(inputC, INPUT);
- pinMode(inputD, INPUT);
- // Setup outputs:
- pinMode(outputW, OUTPUT);
- pinMode(outputX, OUTPUT);
- pinMode(outputY, OUTPUT);
- pinMode(outputZ, OUTPUT);
- }
- void loop() {
- // Read the state of the first input value:
- readState = digitalRead(inputA);
- if (readState == HIGH) {
- // turn LED on:
- digitalWrite(outputW, HIGH);
- }
- else {
- // turn LED off:
- digitalWrite(outputW, LOW);
- }
- // Read the state of the second input value:
- readState = digitalRead(inputB);
- if (readState == HIGH) {
- // turn LED on:
- digitalWrite(outputX, HIGH);
- }
- else {
- // turn LED off:
- digitalWrite(outputX, LOW);
- }
- // Read the state of the third input value:
- readState = digitalRead(inputC);
- if (readState == HIGH) {
- // turn LED on:
- digitalWrite(outputY, HIGH);
- }
- else {
- // turn LED off:
- digitalWrite(outputY, LOW);
- }
- // Read the state of the fourth input value:
- readState = digitalRead(inputD);
- if (readState == HIGH) {
- // turn LED on:
- digitalWrite(outputZ, HIGH);
- }
- else {
- // turn LED off:
- digitalWrite(outputZ, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement