Button - digitalRead(...) problem

Hello.I use Proteus simulator and here is a schematic. I use an arduino nano, an ultrasonic sensor , l293d chip , a DC motor , lcd display and 2 buttons.The pins of each element don't seem (maybe because I use Ubuntu 20.04 running with Wine app, I don't know).
So,my problem is in 2 buttons,when I run the program, lcd displays 0,when I press the right button for 1st time ,it shows 1 ,but as many times as I press it again,lcd displays 1.
Here I have a video of how does it show.

Code: (I only mention the code of reading the button)

#include <LiquidCrystal.h>


LiquidCrystal lcd(9,8,7,6,5,4);

int button_RIGHT = 13;

void setup() 
{
  lcd.begin(20 , 4);
  pinMode(button_RIGHT , INPUT);
}


void loop() 
{  
  lcd.setCursor(0 , 1);
  lcd.print( digitalRead(button_RIGHT) );
}

How does Proteus handle floating inputs?

I have no idea.I dont have much experience with Proteus.I started before a few days just for some tests and last time I used it was 3 years ago

Ok.After 4 hours I realised that I had to connect the button between the pin and GND and not to the VCC

That doesn't stop the pin floating.
A pullup or pull-down resistor on the other hand...

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.