Questions tagged [nxc]

The `nxc` tag is for 'Not eXactly C'.

The tag is for 'Not eXactly C'. This language is described at http://bricxcc.sourceforge.net/nbc/. Apparently, it is an "unofficial" language for the LEGO Mindstorms NXT.

27 questions
3
votes
1 answer

Memory test operation without pointers in NXC on NXT?

I'm trying to write a memory test program for the NXT, since I have several with burned memory cells and would like to identify which NXTs are unusable. This program is intended to test each byte in memory for integrity by: Allocating 64 bits to…
user1131435
2
votes
3 answers

Separate signed int into bytes in NXC

Is there any way to convert a signed integer into an array of bytes in NXC? I can't use explicit type casting or pointers either, due to language limitations. I've tried: for(unsigned long i = 1; i <= 2; i++) { MM_mem[id.idx] = ((val & (0xFF <<…
Mateen Ulhaq
  • 24,552
  • 19
  • 101
  • 135
2
votes
1 answer

implementing PID algorithm in line following robot

I'm working on a small project with NXT mindstorms set. My intention was to build a Robot that can follow a line very smoothly and as fast as possible. Therefore after a small research I found the PID algorithm and I was able to understand and…
james
  • 153
  • 1
  • 13
2
votes
0 answers

NXT like standard C?

I'm currently working on a project, where we want to program a swarm of nxts. I have a question to this one, and I can't find a precise answer on the web. So there will be a program on my pc, let's call it a switch, which should connect to 3…
themaksmw
  • 25
  • 6
2
votes
1 answer

NXC communication through USB

How would you send data through the USB port and receive the data in my Linux machine? task main () { byte data[2] = {1,2}; while (1) { Wait(1000); SetUSBOutputBuffer(0, 2, data); } } Compiled it with: nbc -d -Z2 usb.nxc dmesg: usb 2-1.2:…
ArchHaskeller
  • 1,270
  • 1
  • 12
  • 28
1
vote
2 answers

Converting Byte Array to String (NXC)

Is there a way to show a byte array on the NXTscreen (using NXC)? I've tried like this: unsigned char Data[]; string Result = ByteArrayToStr(Data[0]); TextOut(0, 0, Result); But it gives me a File Error! -1. If this isn't possible, how can I watch…
1
vote
0 answers

RGB To HSL Algorithm?

I have seen many algorithms and formulas for converting RGB data to HSL but none were successful. So where can I get few algorithms/formulas for converting.
Timbelion
1
vote
1 answer

How to control thread's execution order in NXC?

I want to write a parallel program in a preemptive thread scheduling environment and I can use mutex (binary mutexes which are always initialized as not taken), wait instructions, and also thread cooperation instruction (yield to another task in a…
Ali Khalili
  • 1,504
  • 3
  • 18
  • 19
1
vote
1 answer

Difference between NXT-G visual programming and NXC C-like programming of Lego brick

I'm approaching to Lego NXT programming and I started from the very good site http://nxtprograms.com . In particular I followed instructions for the simple Segway with light sensor as balancing sensor…
user1131951
  • 141
  • 7
0
votes
1 answer

How to return array from function in NXC?

How to return array from function in NXC? I tried the following string[] strsplit(string str) { string parts[2] = {"1", "2"}; return parts; } but I get Variable name expected. Why? P.S. if there built-in split function I'll be glad to…
theateist
  • 13,879
  • 17
  • 69
  • 109
0
votes
0 answers

Hello World, Bye Cruel World

I am BRAND new at coding, and don't understand. I know this has probably been asked, but I didn't know how to search this specifically. I am using NXC and a Bricx. How can I display "Hello World", play a sound, then display "Bye Cruel world" beneath…
0
votes
0 answers

Reading characters within a file (the fseek command) not working in nxc (not-exactly-c) programming

Basically I'm trying to write code that reads a specified value from a file ex: file contains(12345) the code reads specific place (say the 3rd place) and the output = 3 I already know how to write numbers to a file but I am stuck on how to read a…
Lukeyboi
  • 1
  • 1
0
votes
1 answer

How to split a string in nxc

I've been trying to convert a python project to nxc using the IDE: Brixc Command Center, so that it'll read a text file and split down the information into components where it can process it. The main road block for me is the split string method…
Joe
  • 3
  • 3
0
votes
1 answer

While Loops - Time

Quick question that I had a hard time finding in the documentation. I am trying to do a while loop that will last for an specific amount of time (like 500ms). How quickly could it do one loop? Every loop will not do a big task, but just read if the…
Diaco
  • 241
  • 1
  • 3
  • 15
0
votes
1 answer

Using mutexes to call separate tasks nXc

I'm new to using nXc to code my NXT 2.0 robot and I need it to follow other robots and check for obstacles at the same time. However, the two tasks sometimes conflict with each other and when I meet an obstacle it treats it as an object and…
Sandra Ng
  • 1
  • 3
1
2