Created
December 22, 2018 16:07
-
-
Save detik19/8241420b5fa6a47ed158115b8a9feb47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LED_A 3 | |
#define LED_B 4 | |
#define LED_C 5 | |
#define LED_D 6 | |
#define BUTTON_A 9 | |
#define BUTTON_B 10 | |
#define BUTTON_C 11 | |
#define BUTTON_D 12 | |
void setup(){ | |
//Serial.begin(9600); // setting the baud rate | |
// Serial.println("RF receiver button decode"); // printing | |
pinMode(LED_A, OUTPUT); | |
pinMode(LED_B, OUTPUT); | |
pinMode(LED_C, OUTPUT); | |
pinMode(LED_D, OUTPUT); | |
pinMode(BUTTON_A, INPUT); | |
pinMode(BUTTON_B, INPUT); | |
pinMode(BUTTON_C, INPUT); | |
pinMode(BUTTON_D, INPUT); | |
} | |
void loop(){ | |
/*here in this code I used if statement to setup my loops codes, yo can also use while loop statements to control the output in the serial monitor*/ | |
if (digitalRead(BUTTON_A) == HIGH) { // Button a pressed | |
// Serial.println("you are pushing on the A"); | |
digitalWrite(LED_A, HIGH); | |
} | |
if (digitalRead(BUTTON_B) == HIGH) { // Button B pressed | |
// Serial.println("you are pushing on B"); | |
digitalWrite(LED_B, HIGH); | |
} | |
if (digitalRead(BUTTON_C) == HIGH) { // Button C pressed | |
// Serial.println("you are pushing on C"); | |
digitalWrite(LED_C, HIGH); | |
} | |
if (digitalRead(BUTTON_D) == HIGH) { // Button D pressed | |
//Serial.println("you are pushing on D"); | |
digitalWrite(LED_D, HIGH); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment