Hello everyone.my name's chatchai.this's my first port and sorry for my english. I have problem with send data to serial. when i push button have a lot data to sent.this my code.
const int led = 13;
const int buttonP = 2;
int btnstate = 0;
void setup() {
// initialize the digital pin as an output.
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(buttonP, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
btnstate = digitalRead(buttonP);
if (btnstate == HIGH)
{
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
Serial.print("13");
}
else
{
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
}
from above code.I need to sent value=13 to serial when i push button.but I got many 13.please see my picture.
Thank you.
