Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Electronic race programing

Status
Not open for further replies.

happyharryh69

New Member
Hello There
I am trying in vain to design a program that will register a 10 pushes of a button and then light an led. This is a race between two players and the program needs to register both players key depressions at the same time.
The first player to light all of his 4 led's is the winner.
I'm having trouble in the starting process of registering the key presses and when 10 have been made on how to light the LED.
Is there away of storing each press of the button until it accumilates 10 presses and then lights the LED, or would it be better to store a value of 10 into a Flag and check against the flag each time the button is pressed.
Could someone please give me some help thanks
 
i would just use a variable for each player... on start, zero them all, then with each button press by that player, increment the counter. have a simple branch to check if the current number of presses is 9... if it is, then light an LED and zero the counter again. you would also need to keep track of which LEDs are lit, so the program doesn't try to light the same one over and over.
 
Hello There
Thanks for the reply, just another quick question
How would I go about setting the program to recognise this.
I just need a little guidence of what instructions to input into the program.
Any help would be greatly received

it sounds like you don't really have any programming experience.
while this program isnt' a terribly challenging one to write, it is not something you are going to be able to sit down and write with little to no experience.

Also, you don't mention what language you are writing the program in, or even what platform you are using. computer? microcontroller?
First off, we're going to need to know those things to provide any help whatsoever.

In any case, you should start by finding some tutorials relevant to your desired language and platform that can get you started in programming, so you can get a working program that does SOMETHING, and then when you know what you are doing you can go back and write a program that actually does what you want. With microcontrollers, the syntax of the language, as well as an understanding of how the various hardware elements inside are actually interacting, are not immediately intuitive; there is a learning curve. It may seem trivial, but often the hardest part of learning to program on a microcontroller is something as simple as getting to the point where you can get it to do something simple like flash a single LED. After that it's just details.
 
re:

Hello again
I'm programming a pic16f84a micro controller using mplab.
I have already started the first part of my program which is just to flash an led 3times before the race starts(succesful).
The problem i have is there are two players who have a push button each.
I need the pic16f84a to register both pushbuttons at the same time and register the counts. When one of the players reaches 10 hits, an led needs to be lit. I thought one way is to register a value of 1010 in a flag and once the 10 hits matches this binary number(checked against the flag) an led could be lit, or the other method of incrementing a count of button presses to 10 and once 10 is reached to light a certain led.
I just need a little help with the instructions i need to define and set the parameters within the program.
 
both of your methods are the same thing, from what I see. you have to count the number of button presses, and you have to check it against 10 (binary 1010)...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top