Code: Select all
int inByte;
const int buttonPin = PA0;
const int ledPin = PC13;
int is_button_press = 0;
int debounce_delay = 300;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
Serial.begin(9600);
Serial2.begin(9600);
}
void loop()
{
is_button_press = digitalRead(buttonPin);
if (Serial2 || is_button_press == HIGH)
{
delay(debounce_delay);
if(is_button_press == HIGH)
{
digitalWrite(ledPin, HIGH);
}
inByte = Serial2.read();
digitalWrite(ledPin, HIGH);
Serial.write(inByte);
delay(100);
}
else
{
digitalWrite(ledPin, LOW);
}
}



output is :
0
0
2
for 0.022 kg. When I remove the delay, the output is:
000.020?????????????????????????????????????????????????????????????????
I thank all for being so grateful. It seems I have to wage a war against the setup. Thanks again...
P.S. If someone suggest me a best e-book to learn arduino programming, I'll be so grateful to ya. Thanks in advance.