Search found 8 matches
- 13 Nov 2013, 11:35
- Forum: Mindstorms Software
- Topic: Having issues with code
- Replies: 14
- Views: 19583
Re: Having issues with code
A few coding pointers that perhaps might help you. #DEFINE should go at the top of your program, outside of any functions or tasks or anything. It is a preprocessor directive, and it tells the compiler (the program that makes your code into something the NXT can run) to replace every following inst...
- 13 Nov 2013, 11:06
- Forum: Mindstorms Software
- Topic: Having issues with code
- Replies: 14
- Views: 19583
Re: Having issues with code
sorry, double post
- 07 Nov 2013, 19:48
- Forum: Mindstorms Software
- Topic: Having issues with code
- Replies: 14
- Views: 19583
Re: Having issues with code
task main (){ #define NEAR 15 // cm SetSensorLowspeed(IN_1); while(true){ OnFwd(OUT_AC,75); while(SensorUS(IN_1)>NEAR); Off(OUT_AC); OnRev(OUT_AC,100); } #define THRESHOLD 29 SetSensorLight(IN_2); OnFwd(OUT_AC,75); while(true){ if (Sensor(IN_2) > THRESHOLD){ OnRev(OUT_C, 75); Wait(100); until(Senso...
- 07 Nov 2013, 16:31
- Forum: Mindstorms Software
- Topic: Having issues with code
- Replies: 14
- Views: 19583
Re: Having issues with code
just add the task code for every additional task and start it in main() or where-ever. "start" is only defined in the enhanced FW (EFW) like many other features, too. So NXC should always only be used with the EFW on the brick. If you haven't already done it: read the BCC manual or the &q...
- 07 Nov 2013, 15:09
- Forum: Mindstorms Software
- Topic: Having issues with code
- Replies: 14
- Views: 19583
Re: Having issues with code
the general pattern is the following: task DoThis() { // // } task DoThat() { // // } task main() { // start DoThis; start DoThat; while( run_condition ) {...;} // } notice that you need to have downloaded (resp. uploaded) John Hansen's enhanced firmware to the brick instead of the original Lego fi...
- 07 Nov 2013, 09:39
- Forum: Mindstorms Software
- Topic: Having issues with code
- Replies: 14
- Views: 19583
Re: Having issues with code
Ok well what could we do to fix this? Because we are three people working on this code and we can't find a solution so it'd be really cool if you could point out what exactly is wrong with it.doc-helmut wrote:it's still quite the samedoc-helmut wrote:you call task main inside a if-loop, that's surely a mistake
- 07 Nov 2013, 09:33
- Forum: Mindstorms Software
- Topic: Having issues with code
- Replies: 14
- Views: 19583
Re: Having issues with code
task check_sensors() { while (true) { #define THRESHOLD 30 task main(){ if (SENSOR_1 == 1) { SetSensorLight(IN_2); OnFwd(OUT_AC, 75); while(true){ if (Sensor(IN_2) > THRESHOLD){ OnRev(OUT_C, 75); Wait(100); until(Sensor(IN_2) <= THRESHOLD); OnFwd(OUT_AC, 75); } } } } #define NEAR 15 // cm task main...
- 07 Nov 2013, 08:59
- Forum: Mindstorms Software
- Topic: Having issues with code
- Replies: 14
- Views: 19583
Having issues with code
Hi, I'm working on a fighting robot for NXT and this is how far we've gotten with our code, it's a school project and we haven't managed to bug fix it ourselves seeing how we are both new to this programming language and we don't have much of a coding background, it's in NXC also it's supposed to st...