Table of Contents

/*
DigitalReadSerial
Reads a digital input on pin 14, prints the result to the Serial Monitor
*/
#include <Arduino.h>
// digital pin 14 has a pushbutton attached to it. Give it a name:
int pushButton = 14;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
Serial.println(buttonState);
delay(1); // delay in between reads for stability
}
Document in project
You can Download PDF file.
Teeratus_R 2024-03-18