16
16
The program in this case would be very similar to the previous. Note that now
when the button is pressed we introduce an “=” at PIN7, therefore, if you want
to start the PIN13 output, you should write in it the value read from the denied
button, i.e. “!value”.
Modi
fi
ed counter program
/ * Detects if connected to the input jack 7 button has been pressed and LED
lights up
* Send the value of the variable ‘Counter’ account via serial port to the PC.
*
*
*/
int LED = 13;
int Button = 7;
int value = 0;
int counter = 0;
int buttonlaststate = 0;
void setup()
{
Serial.begin(9600); // Con
fi
gures transmission speed to 9600
pinMode(LED, OUTPUT); // Initializes as a digital output pin 13
pinMode(Boton, INPUT); // Initializes as a digital input the 7
digitalWrite(Button,HIGH); // Enable internal resistance Pull-up from PIN7
}
void loop()
{