// Write to slashes to comment
// This code is on C++
// First we declare our constants in this case the led and the button
const int ledPin = 17; // The number represents the pin it is connected
const int buttonPin = 4; //If you connect it to another pin other that the one specified it wont work
void setup() { // Void setup is a function that runs just one time, at the beginning (when it powers or resets)
Serial.begin(115200); // The serial begin starts communication at 115200 bits per secong whcih is a pretty good velocity
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {// Void loop is a function that runs continuosly
if (digitalRead(buttonPin) == LOW) { // If the button pressed (low)
digitalWrite(ledPin, HIGH); // the led will turn on (high)
Serial.println("Led On"); // Prints a message to the serial monitor
} else { // If the button not pressed it will happen the contrary
digitalWrite(ledPin, LOW);
Serial.println("Led Off");
}
delay(400); // A small delay so the serial output prints slower
}