/*
Ardiuno_4key_6led
This example code is in the public domain.
*/
//Define the key pin
You K1 = 13;
You K2 = 12;
You K3 = 11;
You K4 = 10;
// Define LED pin
You GND = 6;
you D1 = 5;
you D2 = 4;
you D3 = 3;
you D4 = 2;
you D5 = 1;
you D6 = 0;
// Variables will change:
int buttonState = 0; // Variable to read the push button state
// The setup routine is run once when reset is pressed:
void setup() {
// Initialize the key pin as input.
Pin mode (K1, input);
Pin mode (K2, input);
Pin mode (K3, input);
Pin mode (K4, input);
// Configure the LED pin as an output.
Pin mode (GND, OUTPUT);
Pin mode (D1, OUTPUT);
Pin mode (D2, OUTPUT);
Pin mode (D3, OUTPUT);
Pin mode (D4, OUTPUT);
Pin mode (D5, OUTPUT);
Pin mode (D6, OUTPUT);
// Activate the internal pull-up resistors of the switch pin
digital write(K1, HIGH);
Digital writing (K2, high);
Digital writing (K3, high);
Digital Writing (K4, High);
// as LED GND
Digital Write (GND, LOW);
}
// The loop runs over and over forever:
empty loop() {
Button state = digital readout(K1);
digitalWrite(D1,buttonState); //
Button status = digital reading (K2);
digitalWrite(D2,buttonState); //
Button status = digital readout (K3);
digitalWrite(D3,buttonState); //
Button status = digital readout (K4);
digitalWrite(D4,buttonState); //
digitalWrite(D5, HIGH); // Turn on the LED (voltage level is high)
digitalWrite(D6, HIGH); // Turn on the LED (voltage level is high)
}