Hello
I am trying to help one of my students who is trying to create an Arduino BMI scale. He can obtain the mass of the person from the load cells, but he says that he can input the person's height through the touch buttons on an LCD screen that he intends to use. I have looked up the page and I think that it is only allows scrolling. The link is here https://www.auselectronicsdirect.com.au/2-x-16-lcd-display-controller-shield-for-arduino-d
I would really appreciate it if I could get some feedback regarding the ability to input data such as height directly into the LCD screen, thank you.
Those switches can be read by the program and code execution can be controlled, such as incrementing/decrementing a variable.
As in the example:
int val=analogRead(A0);
val indicates a switch push
Thank you, so if val refers to the switch push. Does this mean that he needs to write some sort of code that prompts the number value to be inputted, for example 1.83 to represent 1.83m?
I am not skilled in programming and am wondering if there would a tutorial that I could work through? Thanks again.
The code on that link gives a good example of the push button usage:
/*
Liquid Crystal Library - Hello World
Demonstrates the use a 16x2 LCD display. The Liquid Crystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD
and shows the time.
The circuit:
* LCD RS pin to digital pin 8
* LCD Enable pin to digital pin 9
* LCD D4 pin to digital pin 4
* LCD D5 pin to digital pin 5
* LCD D6 pin to digital pin 6
* LCD D7 pin to digital pin 7
* Button pin to analog pin A0
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
Serial.begin(9600);
// Print a message to the LCD.
lcd.print("Hello,keyestudio");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
int val=analogRead(A0);
Serial.println(val);
if(val>=0&&val<=50)
{
lcd.setCursor(5,1);
lcd.print("R");
}
else if(val>=50&&val<=150)
{
lcd.setCursor(5,1);
lcd.print("U");
}
else if(val>=150&&val<=300)
{
lcd.setCursor(5,1);
lcd.print("D");
}
else if(val>=300&&val<=500)
{
lcd.setCursor(5,1);
lcd.print("L");
}
else if(val>=500&&val<=750)
{
lcd.setCursor(5,1);
lcd.print("S");
}
}
I don't see how you can enter ten digits 0-9 and perhaps a decimal point with 6 buttons.
While you hold a button down you could auto increment a variable displayed on the LCD.
For example, 185cm would be 6.07 feet.
One button would increment the number, one button would decrement the variable. The number would be in centimetres.
So much information for a non programmer to understand :(. I read through the script in the example and from what I could understand is that inputted characters are directly displayed on the LCD as message. I am having trouble linking in the 5 letters to the output "Hello key studio".
My additional question to your latest reply regarding pressing numbers in increments, can I assume that this feature would need to be programmed into the Arduino code? Or am I totally off the point? Thank you again.
The program is written in C++ on the Arduino.
Depending what is displayed on the screen the buttons can be programmed to react differently.
If the screen said:
Use Up/DWN for height in cm.
Press ENTER
If the up button was held, the number would increment, first slower, then faster. Same with the down button.
A third button is used as an ENTER key when the number on the LCD is correct.
Yes, that is correct.
LarryD and your student are both more clever than I am. Indeed there is a way to use the shield buttons inorder to increment or decrement a staring number.
The analogRead() value says which button is pressed. Its up to the code to determine what to do when it sees a button is pressed.
There is no direct relationship between the buttons and the display. That is all done in code.
No, that’s the way my old microwave worked.
Thank you for all of your time and help, much appreciated. I have passed this onto my student and he found it helpful.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.