// ------------
// ECE 210 - Lab 3
// ------------
/*-------------
Author: Giri Venkataramanan
This code is used in ECE 210 in Practicum 3.
The code demonstrates reading bit level logic signals and sending output of bit level logic signals
Pin D4 is used to read signal input
Pin D2 (red LED) and Pin D11 (green LED) are used to write signal outputs
Pin D2 and D11 are echo of Pin D4
-------------*/
// constants won't change. They're used here to set pin numbers:
const int VL = 4; // the number of the swich pin, VL stands for logic voltage
const int PR = 2; // the number of the LED pin, PR stands for red probe
const int PG = 11; // the number of the LED pin, PG stand for green probe
// variables will change:
int SwitchState; // give a name for the switch state variable
//declares the inputs and outputs of the circuit
void setup() {
pinMode(VL, INPUT);
pinMode(PR, OUTPUT);
pinMode(PG, OUTPUT);
}
// your code written here keeps running until eternity
void loop() {
//reads from the switch to determine which LED should be on
SwitchState = digitalRead(VL);
//turns the red LED on/off based on the switch position
digitalWrite(PR, SwitchState);
//turns the green LED on/off based on the switch position
digitalWrite(PG, SwitchState);
}