Keypad and lcd interface for numbers 0-999 ,help me

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i try to write a code to input numbers by connecting a keypad and a lcd to atmega32 ic.i do it in atmel studio by c language. i initlize lcd and keypad.but i want limit operator only to enter numbers between 0-999. and i want if key# pressed one unit add to entered number and if * presses minus one unit entered number.my problem is i cant store entered numbers in a variable in my code. my code and my 3 question is marked below in code (01code???02code??03code??) please help me it is critical for my boss and my job:

How can i add my c code here??
To see my code and find a way to my problem what should i do?

Aasshh

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Add C code by clicking the "<>" button. That opens a code window. Copy your code, then paste into that code window, and click OK button at the bottom of that window.

 

#include "main.h"

Thats all it takes.

 

It sounds like a concept you are missing is the conversion of (string) characters into numeric values. One way to do this is to use the  atoi() [string to integer] function from avr-libc. To access that, all you have to do is 

 

#include <stdlib.h>

You can read about the function in the avr-libc documentation or in one of the many AS7 help files.

 

Jim

 

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Sun. Aug 4, 2019 - 06:37 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi dear
I use this site by my iphone and so there isnt any button like that you say.

No i know that you say. I can use itoa and libraries. My problem is anywhere else. In making a array by entered key. If i can send yoy my code i explain there.

Aasshh

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

how many keys does your keypad have? 10, 12, or 16?

 

Can you read the  keypad?  Can you display  numbers on the LCD?

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Sun. Aug 4, 2019 - 03:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Aashkanpasha wrote:
Hi dear I use this site by my iphone and so there isnt any button like that you say. No i know that you say. I can use itoa and libraries. My problem is anywhere else. In making a array by entered key. If i can send yoy my code i explain there.
surely you don't write the C code on an iPhone? Try accessing this site in a browser on the same PC where you write the code.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi dear.thanks alot for your attention.

i have a project to interface a keypad and lcd by atmega32.

from morning untill now my all problems solved.

all the codes and all things are correect now  but only one problem.

i enter the number by keypad and lcd shows them, but after 2556 it show 1 again untill 512 then back to 1 again. 

i get intiger numbers and  store in a variable named number and convert it to string by itoa function or sprintf  function (both have same result). why it is so???

please help me.thanks

 

void int2char(y){
	char str[5];
	sprintf(str,"%d",y);
	//itoa(y,str,10);
	alcd_puts(str);
}

......
number=t;
alcd_gotoxy(0,0);
alcd_puts(" Number:");
int2char(number);
state++;
break;
...........

Aasshh

Last Edited: Sun. Aug 4, 2019 - 04:42 PM