mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-13 23:48:46 +01:00
a46259a0cf
Still missing: - updates to WiFi lib for sam. - updates to examples of Ehternet and WiFi for sam. Merge remote-tracking branch 'arduino/master' into ide-1.5.x Conflicts: app/src/processing/app/Base.java app/src/processing/app/Editor.java app/src/processing/app/helpers/FileUtils.java app/src/processing/app/i18n/Resources_fr.po app/src/processing/app/i18n/Resources_fr.properties build/shared/revisions.txt hardware/arduino/avr/libraries/Ethernet/examples/DnsWebClient/DnsWebClient.ino hardware/arduino/avr/libraries/WiFi/examples/WifiChatServer/WifiChatServer.ino hardware/arduino/avr/libraries/WiFi/examples/WifiPachubeClient/WifiPachubeClient.ino hardware/arduino/avr/libraries/WiFi/examples/WifiPachubeClientString/WifiPachubeClientString.ino hardware/arduino/avr/libraries/WiFi/examples/WifiTwitterClient/WifiTwitterClient.ino hardware/arduino/avr/libraries/WiFi/examples/WifiUdpSendReceiveString/WifiUdpSendReceiveString.ino hardware/arduino/avr/libraries/WiFi/examples/WifiWebClient/WifiWebClient.ino hardware/arduino/avr/libraries/WiFi/examples/WifiWebClientRepeating/WifiWebClientRepeating.ino hardware/arduino/avr/libraries/WiFi/examples/WifiWebServer/WifiWebServer.ino libraries/WiFi/examples/WiFiChatServer/WiFiChatServer.ino libraries/WiFi/examples/WiFiPachubeClient/WiFiPachubeClient.ino libraries/WiFi/examples/WiFiPachubeClientString/WiFiPachubeClientString.ino libraries/WiFi/examples/WiFiTwitterClient/WiFiTwitterClient.ino libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino libraries/WiFi/examples/WiFiWebClient/WiFiWebClient.ino libraries/WiFi/examples/WiFiWebClientRepeating/WiFiWebClientRepeating.ino libraries/WiFi/examples/WiFiWebServer/WiFiWebServer.ino libraries/WiFi/examples/WifiChatServer/WifiChatServer.ino libraries/WiFi/examples/WifiPachubeClient/WifiPachubeClient.ino libraries/WiFi/examples/WifiPachubeClientString/WifiPachubeClientString.ino libraries/WiFi/examples/WifiTwitterClient/WifiTwitterClient.ino libraries/WiFi/examples/WifiUdpSendReceiveString/WifiUdpSendReceiveString.ino libraries/WiFi/examples/WifiWebClient/WifiWebClient.ino libraries/WiFi/examples/WifiWebClientRepeating/WifiWebClientRepeating.ino libraries/WiFi/examples/WifiWebServer/WifiWebServer.ino
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
/*
|
|
Keyboard Button test
|
|
|
|
For the Arduino Leonardo, Micro and Due boards.
|
|
|
|
Sends a text string when a button is pressed.
|
|
|
|
The circuit:
|
|
* pushbutton attached from pin 2 to +5V on AVR boards
|
|
and to +3.3V to the Arduino Due
|
|
* 10-kilohm resistor attached from pin 2 to ground
|
|
|
|
created 24 Oct 2011
|
|
modified 27 Mar 2012
|
|
by Tom Igoe
|
|
|
|
This example code is in the public domain.
|
|
|
|
http://www.arduino.cc/en/Tutorial/KeyboardButton
|
|
*/
|
|
|
|
const int buttonPin = 4; // input pin for pushbutton
|
|
int previousButtonState = HIGH; // for checking the state of a pushButton
|
|
int counter = 0; // button push counter
|
|
|
|
void setup() {
|
|
// make the pushButton pin an input:
|
|
pinMode(buttonPin, INPUT);
|
|
// initialize control over the keyboard:
|
|
Keyboard.begin();
|
|
}
|
|
|
|
void loop() {
|
|
// read the pushbutton:
|
|
int buttonState = digitalRead(buttonPin);
|
|
// if the button state has changed,
|
|
if ((buttonState != previousButtonState)
|
|
// and it's currently pressed:
|
|
&& (buttonState == HIGH)) {
|
|
// increment the button counter
|
|
counter++;
|
|
// type out a message
|
|
Keyboard.print("You pressed the button ");
|
|
Keyboard.print(counter);
|
|
Keyboard.println(" times.");
|
|
}
|
|
// save the current button state for comparison next time:
|
|
previousButtonState = buttonState;
|
|
}
|
|
|