source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 4 years ago

Adding new version

File size: 732 bytes
Line 
1/*
2  DigitalReadSerial
3 Reads a digital input on pin 2, prints the result to the serial monitor
4
5 This example code is in the public domain.
6 */
7
8// digital pin 2 has a pushbutton attached to it. Give it a name:
9int pushButton = 2;
10
11// the setup routine runs once when you press reset:
12void setup() {
13  // initialize serial communication at 9600 bits per second:
14  Serial.begin(9600);
15  // make the pushbutton's pin an input:
16  pinMode(pushButton, INPUT);
17}
18
19// the loop routine runs over and over again forever:
20void loop() {
21  // read the input pin:
22  int buttonState = digitalRead(pushButton);
23  // print out the state of the button:
24  Serial.println(buttonState);
25  delay(1);        // delay in between reads for stability
26}
27
28
29
Note: See TracBrowser for help on using the repository browser.