/* * ap_ReadDigital * * Reads an digital input from the input pin and sends the value * followed by a line break over the serial port. * * This file is part of the Arduino meets Processing Project. * For more information visit http://www.arduino.cc. * * copyleft 2005 by Melvin Ochsmann for Malmš University * */ // variables for input pin and control LED int digitalInput = 7; int LEDpin = 13; // variable to store the value int value = 0; void setup(){ // declaration pin modes pinMode(digitalInput, INPUT); pinMode(LEDpin, OUTPUT); // begin sending over serial port beginSerial(9600); } void loop(){ // read the value on digital input value = digitalRead(digitalInput); // write this value to the control LED pin digitalWrite(LEDpin, value); // if value is high then send the letter 'H' else send 'L' for low if (value) serialWrite('H'); else serialWrite('L'); // wait a bit to not overload the port delay(10); }