Pages: [1]   Go Down
Author Topic: how can i confirm my selection using a button  (Read 1595 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

can anybody help? i want to confirm my selection by pressing a button. the selection is a number from my 7 seg display....

can anybody help....URGENTTTTTTTT!!!!!!


1- 7seg display shows number i want
2- press button to confirm selection of number


ANYBODY HELP ME????
Logged

Espoo, Finland
Offline Offline
God Member
*****
Karma: 7
Posts: 586
"Oops, try again..."
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Troll...? Must be...
Logged


The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26378
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

configure a pin as an input with internal pullup resistor enabled. Wire a button to connect the pin to ground.
After your display is set, read the button to see if it went low and go from there.
The button will go 010101010000 a few times (bounce) as you press it, and 10101011111 as you release it, so after you see it change give it a chance to settle before reading it again.
Or use the button library & have it take of debouncing for you.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry, im new at the arduino stuff, its for my assignment and so far most of what i have done is stuff from online reading....but its hard to find stuff about this...isit possible for more detailed help maybe something on a noob level? would be highly appreciated

SO SORRY
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It's not clear what you wanted. Will the number be changing while you get ready to push the button? You should post your assignment, what university and professor smiley-razz
Not getting it is different from not trying it. If you have some code, that is trying, if not, good luck.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the number can be changed using a potentiometer and once you have changed the number to the one you want, i want a button which will confirm the selection....which is also using a beep from a buzzer once it has been confirmed

can anybody help?

i have the potentiometer set with the 7seg display and it changes the numbers when i move it...

Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26378
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What was so hard about what I suggested?
pinMode(select_button, INPUT);
digitalWrite (select_button, HIGH);



put this in the loop as part of twirling your knob
after twirlng knob...

select_button_state = digitalRead (select_button);
if (select_button_state == 0){
// button_pressed =1; // lock in the number

// at the end of your knob twirling loop
if (button_pressed ==1){
// go on to next action
}
something along those lines
}
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have no programming knowledge so it was prety hard for me to understand... thanks allot though...i will give it a go smiley
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26378
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How'd you get thru reading the potentiometer and displaying the digits? That is a lot more complex.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

online reading plus parts of the 1st section were given i just had to add the else ifs to the allready existing if statement
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26378
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

ok, so just add another if around that:
void loop(){

if (button_pushed_state ==1 && locked_in flag = 0){
do all the digit stuff
read the button again}

else{
// button was pushed and not locked in
locked_in flag =1;
}
// do other code
// when all done:
locked_in flag = 0;

} // end void loop
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Espoo, Finland
Offline Offline
God Member
*****
Karma: 7
Posts: 586
"Oops, try again..."
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry quake, after your first post I was convinced that you are just messing with us.

I would like to know, what is your experience level with writing codes, any kind? Just to know where these advices are leading you. Yep, I'm still learning my self C-language, but it is not just writing the code, it's more like thinking the whole or partial prosess in your mind before writing.

Cheers,
Kari
Logged


The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry for the late reply guys ive run out of internet at my uni halls....

well ive started uni, 1st year, not been able to go to much of the c programming lectures/lessons as i dnt stay well...so ive missd allot of stuff...but i understand the very basics.....and thats jus begining of C to be honest...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Quake, I have a sneaky suspicion we might go to the same university. (I'm not going to say which for obvious reasons)

So, the code is quite simple. You need to first define your button at the top of the code as something like:

#define BUT 10 (I think they range from 10-13)

In your code you'll need to setup that button as an input which is done in the setup() function.

pinMode(BUT,INPUT);

In the loop() function you'll need to create a variable and then set it to digitalRead(BUT). Use this variable to check if the buttonState == LOW if is it call the game function.

Hopefully that helps! Good luck for this week. smiley-wink
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the number can be changed using a potentiometer and once you have changed the number to the one you want, i want a button which will confirm the selection....which is also using a beep from a buzzer once it has been confirmed

can anybody help?

i have the potentiometer set with the 7seg display and it changes the numbers when i move it...



I can't work out how to do that !! help!!!
Logged

Pages: [1]   Go Up
Jump to: