Page 1 of 1

Counting

Posted: 02 Oct 2010, 15:45
by mindstormer2010
I'm practically a beginner, I have been learning to use the more advanced blocks in NXT-G , and I just have a question. I was trying to program a robot that would count. I wanted it to display 0 on the screen and every time I pressed the touch sensor it would add one. I know how to put the numbers on the screen, so can someone just help me with the touch sensor and the adding one? Thanks!

Re: Counting

Posted: 02 Oct 2010, 15:48
by mindstormer2010
Oops... I just realized I should have put this in the projects section. Sorry. But can I still have help?

Re: Counting

Posted: 02 Oct 2010, 16:18
by mightor
This forum is fine. Projects is more for finished stuff :)

As for your question, I can really recommend you take a peek at the wonderful tutorials on this site: http://www.ortop.org/NXT_Tutorial/ . You're going to want to pay particular attention to the part about reading sensors inputs, loops and variables.

- Xander

Re: Counting

Posted: 02 Oct 2010, 22:28
by linmix
Follow Xander´s suggestion. You'll lean a lot of useful and interesting stuff.

To get you on the way with your program in NXT-G, first off, you need a place to do the counting: a variable - starting it with a zero value (you can configure that in the variable block config panel) would be a good idea.
Then you need to have a loop that waits for the touch sensor to be bumped (pressed and released) before it will add one (with a math block) to the value of the variable and refresh the screen to show the change.

As you can see, writing down step by step what you want the program to do is half the job done ;)