c program+help me

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

hi.
i want to write a programe for my microproccessor that if one key if pressed for first do task a and if same key pressed for second times do task b and if pressed for third do main function all of this orders must be in a function named for example getkey().
thanks.

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

Why not think of how you would do this with the use of your fingers (and optional use of toes).

David.

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

learning how to use the keyboard would be good start yes :)

Well you could try to learn some C ? I'd guess if you try searching "C tutorial" in google you'll get loars of hits :) well look here, I got 2 170 000 hits :)

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

david.prentice wrote:
Why not think of how you would do this with the use of your fingers (and optional use of toes).

David.


Or the OP might consider using something just a little more important. I've heard it said that using a bit of "Gray Matter " actually multiplies brain cells.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

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

First of all, learn how to ask questions the smart way. Visit this site (There are translations into most languages, so not being able to read English is not an excuse.)

Then visit some of the following:

AVR C tutorial

[TUT] Beginning with everything

[TUT] [HARD] [SOFT] A From-Scratch AVR Tutorial

[TUT] [SOFT] WinAVR Beginner's Quick Start Guide for ATMEGA128

[TUT] [SOFT] Setting Up AVRStudio to use GCC

[TUT] [C] Bit manipulation (AKA "Programming 101")

I know this is a lot of reading, but the tutorials have examples that you can try! I think if you do some of the examples, you will be able to ask better questions.

When you have those better questions, come back.

Best of luck,

Stu

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!

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

Sounds like when you press the button you count... 0..1..2..3... oops! when its 3, set it back to 0! Now do we want to run the task just once? Then we need a 'one shot' of the key being pressed. An 'edge detect'. You need to remember the 'last pass'.... ButtonOneShot=ButtonPressed and not ButtonPressedLastPass; then ButtonPressedLastPass=ButtonPressed; Then you can do something like if ButtonPressedOneShot and (counter==2) then dosomething();

Imagecraft compiler user