nabsteryo Posted April 9, 2013 Posted April 9, 2013 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( https://www.dropbox.com/s/a1y45dl0jchdqsr/number%20to%20motor%20rotation.rbt?m thanks guys! Quote
nabsteryo Posted April 9, 2013 Author Posted April 9, 2013 Hi Carsten, Great thanks... Waiting for it Quote
Carsten Svendsen Posted April 9, 2013 Posted April 9, 2013 (edited) 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 April 10, 2013 by Carsten Svendsen Quote
Someonenamedjon Posted April 9, 2013 Posted April 9, 2013 You can also set a counter on the loop or logic on/off. Quote
nabsteryo Posted April 10, 2013 Author Posted April 10, 2013 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. Quote
Carsten Svendsen Posted April 10, 2013 Posted April 10, 2013 (edited) 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 April 10, 2013 by Carsten Svendsen Quote
nabsteryo Posted April 10, 2013 Author Posted April 10, 2013 Hey Carsten, Ok thanks will try it out tonight. Hows your plane going? Quote
Carsten Svendsen Posted April 10, 2013 Posted April 10, 2013 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? Quote
Someonenamedjon Posted April 11, 2013 Posted April 11, 2013 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.