AVR butterfly using keypad 4x4

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

Hello Dean!

I'm newbei and i'm using keypad as input to my butterfly.
i tried to display on my butterfly lcd based on what i've key in from the keypad.

any ideas how this could be works??

This is my keypad 4x4 AVR-GCC C language:

#include

int main()

{

//high nibble for output(columns) low for input(rows);

DDRB=0xF0;

//enable internal pullups for PB0-PB3

PORTB=0x0F;

//Port D for indication only

DDRD=0xFF;

while (1) //loop key check forever

{

//first column

PORTB =0b01111111;

//check for rows and send key number to portD

//instead sending key number to PORTD you can use

// any function that serves pressed button

if (bit_is_set(PINB, 3)) PORTD=1;

if (bit_is_set(PINB, 2)) PORTD=2;

if (bit_is_set(PINB, 1)) PORTD=3;

if (bit_is_set(PINB, 0)) PORTD=4;

//second column

PORTB =0b10111111;

if (bit_is_set(PINB, 3)) PORTD=5;

if (bit_is_set(PINB, 2)) PORTD=6;

if (bit_is_set(PINB, 1)) PORTD=7;

if (bit_is_set(PINB, 0)) PORTD=8;

//third column

PORTB =0b11011111;

if (bit_is_set(PINB, 3)) PORTD=9;

if (bit_is_set(PINB, 2)) PORTD=10;

if (bit_is_set(PINB, 1)) PORTD=11;

if (bit_is_set(PINB, 0)) PORTD=12;

//fourth column

PORTB =0b11101111;

if (bit_is_set(PINB, 3)) PORTD=13;

if (bit_is_set(PINB, 2)) PORTD=14;

if (bit_is_set(PINB, 1)) PORTD=15;

if (bit_is_set(PINB, 0)) PORTD=16;

}

}

Please help me to display any character on my lcd. :cry:

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

Quote:
I'm newbei

Then the first thing you should do is read the forum guidelines so that you know which of forums this post belongs in.

Regards,
Steve A.

The Board helps those that help themselves.

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

i'm currently found code for my keypad
when i compile it, there is an error

Quote:
c:/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr5/crtm169.o:(.init9+0x0): undefined reference to `main'

what does it mean??

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

That you don't have a function anywhere in your program called main() which is a bit of a shame as that's the entry point for all C programs.

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

For your next problem (once you get your build issues solved):

Take a look at your scan routines - you set one column low to select it and check for rows being high. Also, you have no debouncing there so you will likely get multiple outputs for each keypress and release.

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

i try tu put main() but still have error

FYI, im using dean's keypad program

Attachment(s): 

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

Quote:

i try tu put main() but still have error

Not in the C file posted below that quote you didn't. It contains on a single function called KPDScan(). Either rename that to main() or add a short main() that invokes that function.

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

hi there

i found a c program for keypad from internet but the keypad is connected to other microcontroller, not butterfly

my question is can i use this program and run it with avr studio?

thanks

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

Probably not without some changes, but we really can't tell until you show the code.

It sounds like you are trying too much here. Start by getting an LED to blink at the correct rate. This will make sure you know how to write, compile, link, and load programs.

Then work on getting the LCD or serial port running so you have some way of getting debug output from your code.

Then finally, add the keypad code. The code you have at the beginning of this thread isn't too bad of a first start *if* you fix the bugs in it. Once it works, you can add debouncing, but first get the basic version going.
/mike