I am trying to make my project switch between displaying centigrade and fahrenheit everytime i press a button. I have it all connected ok, but the only way i can seem to get it to work is if i hold the button down. But i want it to 'switch' everytime i press the button instead.
I am trying to make my project switch between displaying centigrade and fahrenheit everytime i press a button. I have it all connected ok, but the only way i can seem to get it to work is if i hold the button down. But i want it to 'switch' everytime i press the button instead.
Any help would be excellent.
There is no circuit diagram or wiring plan available?
Simplest possible button circuit would be:
Connect a wire from pole-1 of the push button to an Arduino pin and pole-2 of the push button to GND
(Don't use any external pull up resistor or pull-down resistor)
Instead activate the "internal pull-up resistor of the Atmega controller within the setup()
pinMode(switchOne,INPUT_PULLUP);
Does it sound doable?
BTW: If you want to update the display once every second, while it is possible to change from Celsius to Fahrenheit at any time between, you better get rid of the delay and do all timings just using millis().
Which is going to be the initial state for the display, used before any button is pressed: Initially Celsius or initially Fahrenheit?
But be warned, untested code, I just wrote it down.
I tested only that it compiles error-ree, otherwise fully untested!
As it is, the code is activating and using internal pull-up resistor. With your Fritzing and external pull-down resistor you may find, that switching from Celsius to Fahrenheit and other way round does not happen when pressing the button, but when releasing the button.