--- /dev/null
+(how to use this
+ (connect your robot to your computer via usb cable)
+ (open arduino ide)
+ (in arduino ide, open pushbutton.ino)
+ (hit the upload button)
+ (hit control+shift+m,
+ or go to the menu item tools, and down to serial monitor)
+ (in the bottom right, select "9600 baud")
+ (connect the breadboard and pushbutton as shown in "pushed.jpg")
+ (hit the upload button in the arduino ide)
+ (press the ))
\ No newline at end of file
--- /dev/null
+/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// pin 13 controls the arduino's built-in LED
+int led_pin = 13;
+// connect the button to pin 2
+int button_pin = 2;
+// initially, the button is not pressed.
+// 0 means not pressed, 1 means pressed
+int button_value = 0;
+
+void setup(){
+ Serial.begin(9600);}
+
+void loop(){
+ // see if you can figure out how this logic works
+ if(digitalRead(button_pin) != button_value){
+ Serial.println("button state changed!");}
+ // read the value of the button pin during this loop,
+ // and save it in a box named "button_value"
+ button_value = digitalRead(button_pin);
+ // write the value to the led pin
+ digitalWrite(led_pin, button_value);}