I am working on a project that continuously turns 256 water jets (LEDs, for forum purposes…) on and off using 1 Arduino and 32 shift registers (each of which controls 8 of the jets/LEDs). The algorithm to determine which jets go on/off continuously updates in Matlab. I then form the 32 bytes to send via serial from Matlab to the Arduino (and it gets sent to each shift register in turn). In theory, very straightforward.
My serial code works to send the bytes from Matlab to the Arduino. However, once read into the Arduino, I can print these digits back out but they are not activating the shift registers. I think the shift register is seeing them as strings instead of ints, but do not know if that’s the problem, nor how to fix it. Any ideas? I tried simple “atoi” stuff with no luck, but very open to suggestions!
Simplified but functioning Matlab serial portion of script:
s = serial(’/dev/tty.usbmodem411’,‘BaudRate’,19200)
Simple Arduino code attached, for 2 shift registers at a time: note, this will print “28” and “52” several times, but no LEDs light up. whereas if I typed directly:
shiftOut(dataPin, clockPin, MSBFIRST, 28);
shiftOut(dataPin, clockPin, MSBFIRST, 52);
then I do see success. ideas???
sketch_aug18a.ino (1.2 KB)