Sign in to follow this  

Recommended Posts

Dear all,

I want to create a programme that counts how many times i click and transforms this value into how many rotations the motor should rotate. Obviously i need a second button to tell nxt "OK" thats how many rotations i want. That in my programme is button "2".

i attached the programme, could some one please help me as i am very new to programming and i dont know if its the most elegant solution. It doesnt even work actually :s. i cant figure out how to make a counter other than by using the counter of the LOOP funtion.

below is the drop box link..please somebody help me as i am so frustrated( :cry_happy:

https://www.dropbox.com/s/a1y45dl0jchdqsr/number%20to%20motor%20rotation.rbt?m

thanks guys!

Share this post


Link to post
Share on other sites

Sorry it took so long, it was a bit more complicated than I thought.

Here is the file: EDIT: See post #9

I haven't tested it, but I'm pretty sure it'll work like this:

- Bump the touch sensor to select the amount of degrees in a 90° interval

- Press and hold the touch sensor for 2 seconds or more to start the motor

- Press and hold the touch sensor for 4 seconds or more to reset the selected amount of degrees. - Now you can start over.

I don't know if the variables are saved in the file, but if not, you have to go to "Edit" -> "Define Variables" -> "Create", then create a "Logic 2" and a "Number 2" variable.

Edited by Carsten Svendsen

Share this post


Link to post
Share on other sites

Hi Carsten, okay thanks I will try it in a bit... Never used variables but will try and reverse engineer what u did. Amazing plane by the way.

Thank u very much.

Share this post


Link to post
Share on other sites

I just tested it my self after I finally got my brick working again. It turned out that the program didn't work at all, but mostly because some program steps were interfering with one another

Here is a file that's in 100% working condition, and works exactly like I said previously: EDIT: See post #9

Greetings!

Edited by Carsten Svendsen

Share this post


Link to post
Share on other sites

Don't use the program above, I discovered a minor flaw; When you have entered a number (with the touch sensor) and you want to reset it by holding it down for 4 seconds, when you release the touch sensor, it will add a number.

I fixed it: http://www8.zippyshare.com/v/2063107/file.html

Out of curiosity, what are you going to do with such a simple program?

And my plane? Well, at this rate I'll never finish it. Hopefully, I can get some work done on the tail tomorrow

You can also set a counter on the loop or logic on/off.

I can't get that to work. Can you please give me an example of this program using that method?

Share this post


Link to post
Share on other sites

i can't program it right now, but you can have data wires going to the loop, so you could have a Bluetooth message says false, and then receiving it and connecting the data wire to the loop block, you can see the data wire inlet at the beginning of the loop, you can also use any block that can define something as true of false, like the touch sensor.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.