Arduino Uno as a Led Strip Controller

Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #196181
    2borG
    Participant
      @2borg

      Having an Arduino Uno lying around I didn’t want to spend another 70€ or 80€ in a Teensy and OctoWS2811 adapter to drive a couple of leds.

      The Arduino Uno one major advantage to the Teensy. It’s capable of controlling the 5V Leds Strip directly, so almost no extra hardware is needed.

      The code from the TeensyStrip,  was adapted to work with the Uno, resulting controller not so powerful as TeensyStrip, but still capable of driving a couple hundred leds without a problem.

      This has full compatibility with TeensyStrip, so all tutorials on how to configure led strips are valid without any change.

      You’ll only need 5V Led Strips (WS2812), an Arduino and one 100Ohm resistor for each led strip you want to control.

      I’ve attached the Arduino Code, a diagram of the connections and a sample cabinet.xml .

       

      <hr />

      V1.5

      Some bug fixes due to different type sizes from Teensy and Uno

      All strip lengths are created dynamically to save memory

      Port speed updated to 921600 (working perfectly in my setup)

      Various speed optimizations trying to compensate Uno being slower than Teensy.

       

       

      1 user thanked author for this post.
      #196579
      Johnny T
      Participant
        @johnnyt

        I’ve just started learning about DOF (after spending the weekend learning about VPX). I’ve got some WS2811 LEDs and an Arduino Uno so was reading on how (if) I could get the two talking. I found a lot about using Teensy etc but then stumbled upon your brilliant post!

        I’ve not dug right into this as I’m wanting to watch all the TerryRed series of videos on DOF (and DOFLinx for Future Pinball) first to give myself a good grounding in it but this looks very promising. I’ve already got the LEDs working from the Arduino (using the FastLED library) so now I’m going to try and stand on the shoulders of giants and tweak your script to suit my setup.

        Just looking at the DOFConfig tool for the first time there’s no mention of an Arduino. But then looking through your xml it references “LedWizEquivalent 30”.

        Does DOF see an Arduino as an LEDWiz? If so, should I be ticking that box?

        If you had a picture of your DOFConfig tool settings that would be very helpful I think (or maybe you don’t need the DOFConfig tool and you just edit the xml directly?)

        Either way, just wanted to say a big thank you for sharing your work. It’s really appreciated and given me something to tinker with. I would have probably never got to where you’ve got to so it’s really helped me out.

        Thanks :-)

        #196581
        jodadek455
        Participant
          @jodadek455

          Hi Johnny

          In DOFConfig tool you should add 1 to the “Number of WS2811 Devices” not in LedWiz devices. Then you should just (at least for now) click the “Generate Config” in the “Port assignments” tab. You need to put the dowloaded files in you DirectOutput config folder.

          Also you need to configure your cabinet.xml file to your hardware. The most important setting is the COM port. This file has to be directly edited. Just use the sample from the zip as a starting point.

          Another important aspect is the version of the DirectOutput. It must be at least “DirectOutput Framework R3++, Grand Unified Edition”. Older versions doesn’t have the “BaudRate” setting, so it wont work.

          Finally… You don’t have to mess with the arduino code. It just receives the data from DirectOutput and send it to the leds. What DOF config does is create the effects to every table. You can mess with that later :)

          I know… It’s not simple, I’m a completely newbie on this, so I’m struggling  myself trying to understands all this :)

           

           

           

           

           

           

           

           

           

          1 user thanked author for this post.
          #196582
          Johnny T
          Participant
            @johnnyt

            That’s great, thanks!

            I think I’ll need to tweak the arduino code as my LEDs aren’t NeoPixel ones. Or does that not matter?

            I’ll have a proper play about with it this weekend. I’ve just had a delivery from eBay of two Siemens contactors too which I’m hoping to use to give some ‘clunking’ feedback to the player. My cabinet is an arcade cabinet that I built. I have put programmable LEDs up the sides though so I’m hoping a couple of contactors and programming the LEDs to follow the pinball games will really add to the effect of it.

            If I manage it I’ll post back with anything that I have found that might be useful to others.

            Cheers :-)

            #196594
            NailBuster
            Moderator
              @nailbuster

              FYI.  there’s already a project similar that uses the $3 esp8266 (WeMOS d1-mini) type that controls all of their led strips with DOF (no extra hardware needed).  Ive used it for years with my matrix with no issues.

              Just letting you know as you can find the source-code already for that and should run ok on your UNO if you needed.   But the esp8266 has advantage of baud rate which is much faster.  almost 1mbit baud.

               

               

              1 user thanked author for this post.
              #196637
              Johnny T
              Participant
                @johnnyt

                Thanks for the info NailBuster and, while you’re here, may I just say a massive Thank You for all your hard work for the community. I just read your reply and then saw your username and thought “Where have I heard that name before” and I quickly realised it’s because I’ve been immersed in all yours and TerryReds tutorials all weekend.

                Thanks to you and Terry I’ve now got Future Pinball and VPX fully set up with the excellent PinUpPlayer all working correctly and tonight I have just (I mean literally “just” – I got back in the house about 10 minutes ago) installed 2 Siemens contactors in my cabinet and successfully got them linked to my flippers via DOF (again, all thanks to the excellent tutorials).

                I can’t imagine the amount of work you and Terry have put into this hobby but I can see why. It’s very addictive. I’ve just ordered 5 more contactors from eBay… :-)

                I’ve only got an arcade cabinet (just one I built myself) as I haven’t got the room for a full size pinball cab (I would absolutely love one though!!) and I really like all the MAME games etc. but VPX is my goto game at the moment. Anyway… I’m rambling…. really just wanted to say Thank you :-)

                #196662
                Johnny T
                Participant
                  @johnnyt

                  Anyone looking at this thread who wants the code that NailBuster mentions, I tracked it down to here:

                  https://github.com/aetios50/PincabLedStrip

                  I’ve not done anything with it yet so can’t confirm whether it works or not but will post back when I do some testing (hopefully at the weekend).

                   

                  #197193
                  Johnny T
                  Participant
                    @johnnyt

                    Hi Johnny

                    In DOFConfig tool you should add 1 to the “Number of WS2811 Devices” not in LedWiz devices. Then you should just (at least for now) click the “Generate Config” in the “Port assignments” tab. You need to put the dowloaded files in you DirectOutput config folder.

                    Also you need to configure your cabinet.xml file to your hardware. The most important setting is the COM port. This file has to be directly edited. Just use the sample from the zip as a starting point.

                    Another important aspect is the version of the DirectOutput. It must be at least “DirectOutput Framework R3++, Grand Unified Edition”. Older versions doesn’t have the “BaudRate” setting, so it wont work.

                    Finally… You don’t have to mess with the arduino code. It just receives the data from DirectOutput and send it to the leds. What DOF config does is create the effects to every table. You can mess with that later :)

                    I know… It’s not simple, I’m a completely newbie on this, so I’m struggling myself trying to understands all this :)

                    Hi guys,

                    I’m just looking into these LEDs now. I’ve fitted a couple of contactors in my cabinet and they are working from Flipper presses. And I’ve also got my ‘Start’ button flashing from a iPac Ultimate so the last thing to get working (before setting everything up properly) are the side LEDs.

                    I’ve installed your software @jodadek455 thanks :-)

                    My arduino is on Com Port 3 so I’ve changed that in the cabinet.xml file. In my Device Manager my Com Port was originally showing 9600 baud so I’ve changed that to 115200. From the arduino software I can input a “T” (Test) and the first 50 or so LEDs cycle through about 5 colours and then go off.

                    But, when I’ve run a table on VPX (Masters of the Universe) there are no lights at all?

                    Do I need to put something in my port assignments in the DOF Config tool? Currently I’ve left my WS2811 device just at default (blank)?

                    I’m not sure what to do from here? Any help/advice would be brilliant.

                    Thanks for any help/guidance you can give :-)

                    #197198
                    Johnny T
                    Participant
                      @johnnyt

                      Right I’m getting a bit further now… I’ve just set up the Global Config file and set up the Combos for the LEDs in the Port Assignment editor. Left/Right/Back on ports 1,4,7.

                      Still not working but finding out more and more…. :-)

                      #197208
                      2borG
                      Participant
                        @2borg

                        Are plugins enabled in the B2s? Right click on the backglass to verify.

                        1 user thanked author for this post.
                        #197221
                        Johnny T
                        Participant
                          @johnnyt

                          I am pretty sure they are. I did do that last weekend when I was setting everything up but I will double check.

                          Just another questions – when I’m in my Arduino software I can open my Serial Monitor and input “T” (Test) to get the LEDs to light up. If I leave that box open, is that box meant to show up any input coming from the DOF software? If so, then I’m not receiving anything but I wasn’t sure if that box would work like that? Or whether, by leaving it open, I’m somehow interrupting DOF from communicating with the Arduino?

                          Also… another question (if you or someone else knows) is there any way I can send some ‘test’ commands from DOF in order to try and trigger the LEDs so that I’m constantly opening VPX / loading a table / trying it / closing VPX / changing a setting / rinse/repeat? It would be good if there was a setting that would (for instance) just send a ‘light up all left hand LEDs’ command once every second or something and then I could see if I was receiving it at the Arduino end?

                          Many thanks for all your help 2borG. Much appreciated :-)

                          #197229
                          2borG
                          Participant
                            @2borg

                            I think you need to close the serial monitor. With that open you’re blocking DOF from accessing the port.

                            I don’t know any other way to test the leds. I’m using the same method as you and it’s a pain….

                            Use the DirectOutputConfigTester and check the log for clues. I just moved the led strip from my computer to the cabinet and took me a while to get it to work.

                            1 user thanked author for this post.
                            #197413
                            Johnny T
                            Participant
                              @johnnyt

                              I think you need to close the serial monitor. With that open you’re blocking DOF from accessing the port.

                              I don’t know any other way to test the leds. I’m using the same method as you and it’s a pain….

                              Use the DirectOutputConfigTester and check the log for clues. I just moved the led strip from my computer to the cabinet and took me a while to get it to work.

                              After lots and lots of trial and error I’m maybe getting somewhere but I’m still stuck….

                              I have downloaded the DOF Test Table and have found that when I run the table my system is trying to communicate with my arduino.

                              It writes the DirectOutput.log which says:

                              2020.08.22 15:48:03.583 Framework initialized.
                              2020.08.22 15:48:03.583 Have fun! :)
                              2020.08.22 15:48:03.765 EXCEPTION: TeensyStripController LEDStripController updater thread could not connect to the controller. Thread will quit.
                              2020.08.22 15:48:03.765 EXCEPTION: Thread: TeensyStripController LEDStripController updater thread
                              2020.08.22 15:48:03.765 EXCEPTION: Message: Exception –> Expected 3 bytes containing data on the max number of leds per channel, but the read operation resulted in a exception. Will not send data to the controller
                              2020.08.22 15:48:03.767 EXCEPTION: Stacktrace: at DirectOutput.Cab.Out.AdressableLedStrip.TeensyStripController.ConnectToController()
                              2020.08.22 15:48:03.767 EXCEPTION: Stacktrace: at DirectOutput.Cab.Out.OutputControllerCompleteBase.UpdaterThreadDoIt()
                              2020.08.22 15:48:03.767 EXCEPTION: Targetsite: Void ConnectToController()
                              2020.08.22 15:48:03.767 EXCEPTION: InnerException 1: Exception –> A TimeoutException occured while trying to read byte 1 of 3 from Com-Port COM2.
                              2020.08.22 15:48:03.767 EXCEPTION: InnerException 2: TimeoutException –> The operation has timed out.
                              2020.08.22 15:48:13.730 Finishing framework
                              2020.08.22 15:48:13.742 Finishing cabinet

                               

                              I’ve attached the full DirectOutput.log to this post in case there is other info in there I’ve missed. (** It wouldn’t let me attach my DirectOutput.log for security reasons but if you want it then let me know and I’ll paste it into a reply ***)

                              I believe this is the problem:

                              Exception –> Expected 3 bytes containing data on the max number of leds per channel, but the read operation resulted in a exception. Will not send data to the controller

                              I thought it might be my COM port so I changed to COM port 2. My settings are:

                              com port settings

                              The DOF framework is sending an “M” to the Arduino (I’ve set up my LEDs to display different colours and different LEDs depending on what the DOF sends so I can try and work out what’s happening. My Arduino code is running the SendMaxNumberOfLeds() function back to DOF.

                              The function looks like this:

                              //Sends the max number of leds per strip
                              void SendMaxNumberOfLeds() {
                              byte B = MaxLedsPerStrip >> 8;
                              Serial.write(B);
                              B = MaxLedsPerStrip & 255;
                              Serial.write(B);
                              Ack();
                              }

                              //Sends a ack (A)
                              void Ack() {
                              Serial.write(‘A’);
                              }

                              So it looks like it’s loading the max number of LEDs (50 is the arbitary number I have in here). It’s shifting value to the right by 8 bits (which, unless I’m mistaken makes ‘B’ equal to zero as it’ll just push the 50 off the byte? It then sends that to DOF.

                              Then it ANDs 50 and 255 and sends that to DOF.

                              It then sends an “A” letter to DOF.

                              However DOF is saying that it expected 3 bytes and didn’t get anything?

                              My full arduino code is here (ignore all the references to ledStrip[0].setPixelColor(jtrandled, BLUE); etc.. that’s just so I can test the LEDs).

                              /********************************************************************************************************
                              ** Arduino Strip Controller
                              ** ———————-
                              **
                              ** This Sketch turns a Arduino into a controller for WS2811/WS2812 based led strips.
                              ** This strip controller was originally designed for use with the Direct Output Framework, but since
                              ** the communication protocol is simple and communication uses the virtual com port of the Arduino
                              ** it should be easy to controll the strips from other applications as well.
                              **
                              ** Most of the code as been copied from the TeensyStrip Controller, but the OctoWS2811 library
                              ** was replaced with the Adafruit_NeoPixel one for compatibility with Arduino
                              **
                              ** https://github.com/DirectOutput/TeensyStripController
                              **
                              **
                              *********************************************************************************************************/
                              /*
                              License:
                              ——–
                              Permission is hereby granted, free of charge, to any person obtaining a copy
                              of this software and associated documentation files (the “Software”), to deal
                              in the Software without restriction, including without limitation the rights
                              to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
                              copies of the Software, and to permit persons to whom the Software is
                              furnished to do so, subject to the following conditions:
                              The above copyright notice and this permission notice shall be included in
                              all copies or substantial portions of the Software.
                              THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
                              IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
                              FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
                              AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
                              LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
                              OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
                              THE SOFTWARE.

                              Required Connections
                              ——————–
                              pin 2: LED Strip #1 10 possible LED Strips.
                              pin 3: LED strip #2
                              pin 4: LED strip #3
                              pin 5: LED strip #4 A 100 ohm resistor should used
                              pin 6: LED strip #5 between each Teensy pin and the
                              pin 7: LED strip #6 wire to the LED strip, to minimize
                              pin 8: LED strip #7 high frequency ringining & noise.
                              pin 9: LED strip #8
                              pin 10: LED strip #9
                              pin 11: LED strip #10
                              pin 12: Test Button. Ground to Test

                              */

                              #include <elapsedMillis.h>
                              #include <Adafruit_NeoPixel.h>

                              #define FirmwareVersionMajor 1 // Definiton of Major and Minor part of the firmware version. This value can be received using the V command.
                              #define FirmwareVersionMinor 1 // If something is changed in the code the number should be increased.

                              #define MaxLedsPerStrip 50 //Defines the max number of leds which is allowed per ledstrip.

                              #define LedPin 2 // Defines the Pinnumber to which the built in led is connected.
                              #define TestPin 12 // Defines the Pinnumber for the test button which is low when pressed

                              elapsedMillis BlinkTimer; // Variable used to control the blinking and flickering of the led of the Teensy
                              int BlinkMode;
                              elapsedMillis BlinkModeTimeoutTimer;

                              const int config = NEO_GRB + NEO_KHZ800; // Config definition for the OctoWS2811 lib. Dont change the color order (even if your strip are GRB). DOF takes care of this issue (see config of ledstrip toy)

                              word stripLength=60;
                              word numStrips=10;

                              Adafruit_NeoPixel ledStrip[] = {
                              Adafruit_NeoPixel(stripLength, 2, config),
                              Adafruit_NeoPixel(stripLength, 3, config),
                              Adafruit_NeoPixel(stripLength, 4, config),
                              Adafruit_NeoPixel(stripLength, 5, config),
                              Adafruit_NeoPixel(stripLength, 6, config),
                              Adafruit_NeoPixel(stripLength, 7, config),
                              Adafruit_NeoPixel(stripLength, 8, config),
                              Adafruit_NeoPixel(stripLength, 9, config),
                              Adafruit_NeoPixel(stripLength, 10, config),
                              Adafruit_NeoPixel(stripLength, 11, config)
                              };

                              //Setup of the system. Is called once on startup.
                              void setup() {
                              Serial.begin(115200);

                              //Initialize the lib for the leds. One instance for each pin, starting pin 2
                              for (int i=0; i<numStrips; i++) {
                              ledStrip.begin();
                              ledStrip.clear();
                              }

                              pinMode(LedPin,OUTPUT); //Initialize the led pin
                              //pinMode(TestPin,INPUT_PULLUP); //Initialize and find value of the test pin

                              SetBlinkMode(0);
                              }

                              //Main loop of the programm gets called again and again.
                              void loop() {

                              // run test if button is grounded
                              if (! digitalRead(TestPin) && false) {
                              Test();
                              }

                              //Check if data is available
                              if (Serial.available()) {

                              byte receivedByte = Serial.read();

                              switch (receivedByte) {
                              case ‘L’:
                              randomLEDlit(receivedByte);
                              //Set length of strips
                              SetLedStripLength();
                              break;
                              case ‘T’:
                              randomLEDlit(receivedByte);
                              //Test
                              Test();
                              break;
                              case ‘F’:
                              randomLEDlit(receivedByte);
                              //Fill strip area with color
                              Fill();
                              break;
                              case ‘R’:
                              randomLEDlit(receivedByte);
                              //receive data for strips
                              ReceiveData();
                              break;
                              case ‘O’:
                              randomLEDlit(receivedByte);
                              //output data on strip
                              OutputData();
                              break;
                              case ‘C’:
                              randomLEDlit(receivedByte);
                              //Clears all previously received led data
                              ClearAllLedData();
                              break;
                              case ‘V’:
                              randomLEDlit(receivedByte);
                              //Send the firmware version
                              SendVersion();
                              break;
                              case ‘M’:
                              randomLEDlit(receivedByte);
                              //Get max number of leds per strip
                              SendMaxNumberOfLeds();
                              break;
                              default:
                              // no unknown commands allowed. Send NACK (N)
                              Nack();
                              break;
                              }
                              SetBlinkMode(1);
                              }
                              Blink();
                              }

                              void randomLEDlit(byte receivedByte){
                              #define RED 0x001600
                              #define GREEN 0x160000
                              #define BLUE 0x000016
                              #define YELLOW 0x141000
                              #define PINK 0x001209
                              #define ORANGE 0x041000
                              #define WHITE 0x101010
                              #define BLACK 0x000000
                              int a = 20000; //this sets how long the stays one color for
                              int ledcolor = random(3); //this randomly selects a number between 0 and 6
                              int jtrandled = random(30, 40);
                              switch (receivedByte) {
                              case ‘L’:
                              ledStrip[0].setPixelColor(jtrandled, GREEN);
                              ledStrip[0].show();
                              delay(a);
                              ledStrip[0].setPixelColor(jtrandled, BLACK);
                              ledStrip[0].show();
                              break;
                              case ‘F’:
                              ledStrip[0].setPixelColor(jtrandled, RED);
                              ledStrip[0].show();
                              delay(a);
                              ledStrip[0].setPixelColor(jtrandled, BLACK);
                              ledStrip[0].show();
                              break;
                              case ‘R’:
                              ledStrip[0].setPixelColor(jtrandled, BLUE);
                              ledStrip[0].show();
                              delay(a);
                              ledStrip[0].setPixelColor(jtrandled, BLACK);
                              ledStrip[0].show();
                              break;
                              case ‘O’:
                              ledStrip[0].setPixelColor(jtrandled, GREEN);
                              ledStrip[0].setPixelColor(jtrandled+1, GREEN);
                              ledStrip[0].show();
                              delay(a);
                              ledStrip[0].setPixelColor(jtrandled, BLACK);
                              ledStrip[0].setPixelColor(jtrandled+1, BLACK);
                              ledStrip[0].show();
                              break;
                              case ‘C’:
                              ledStrip[0].setPixelColor(jtrandled, RED);
                              ledStrip[0].setPixelColor(jtrandled+1, RED);
                              ledStrip[0].show();
                              delay(a);
                              ledStrip[0].setPixelColor(jtrandled, BLACK);
                              ledStrip[0].setPixelColor(jtrandled+1, BLACK);
                              ledStrip[0].show();
                              break;
                              case ‘V’:
                              ledStrip[0].setPixelColor(jtrandled, BLUE);
                              ledStrip[0].setPixelColor(jtrandled+1, BLUE);
                              ledStrip[0].show();
                              delay(a);
                              ledStrip[0].setPixelColor(jtrandled, BLACK);
                              ledStrip[0].setPixelColor(jtrandled+1, BLACK);
                              ledStrip[0].show();
                              break;
                              case ‘M’:
                              ledStrip[0].setPixelColor(jtrandled, RED);
                              ledStrip[0].setPixelColor(jtrandled+1, BLUE);
                              ledStrip[0].setPixelColor(jtrandled+2, GREEN);
                              ledStrip[0].show();
                              delay(a);
                              ledStrip[0].setPixelColor(jtrandled, BLACK);
                              ledStrip[0].setPixelColor(jtrandled+1, BLACK);
                              ledStrip[0].setPixelColor(jtrandled+2, BLACK);
                              ledStrip[0].show();
                              break;
                              default:
                              // no unknown commands allowed. Send NACK (N)
                              Nack();
                              break;
                              }

                              }

                              //Sets the mode for the blinking of the led
                              void SetBlinkMode(int Mode) {
                              BlinkMode = Mode;
                              BlinkModeTimeoutTimer = 0;
                              }

                              //Controls the blinking of the led
                              void Blink() {
                              switch(BlinkMode) {
                              case 0:
                              //Blinkmode 0 is only active after the start of the Teensy until the first command is received.
                              if(BlinkTimer<1500) {
                              digitalWrite(LedPin,0);
                              } else if(BlinkTimer<1600) {
                              digitalWrite(LedPin,1);
                              } else {
                              BlinkTimer=0;
                              digitalWrite(LedPin,0);
                              }
                              break;
                              case 1:
                              //Blinkmode 1 is activated when the Teensy receives a command
                              //Mode expires 500ms after the last command has been received resp. mode has been set
                              if(BlinkTimer>30) {
                              BlinkTimer=0;
                              digitalWrite(LedPin,!digitalRead(LedPin));
                              }
                              if(BlinkModeTimeoutTimer>500) {
                              SetBlinkMode(2);
                              }
                              break;
                              case 2:
                              //Blinkmode 2 is active while the Teensy is waiting for more commands
                              if(BlinkTimer<1500) {
                              digitalWrite(LedPin,0);
                              } else if(BlinkTimer<1600) {
                              digitalWrite(LedPin,1);
                              } else if(BlinkTimer<1700) {
                              digitalWrite(LedPin,0);
                              } else if(BlinkTimer<1800) {
                              digitalWrite(LedPin,1);
                              }else {
                              BlinkTimer=0;
                              digitalWrite(LedPin,0);
                              }
                              default:
                              //This should never be active
                              //The code is only here to make it easier to determine if a wrong Blinkcode has been set
                              if(BlinkTimer>2000) {
                              BlinkTimer=0;
                              digitalWrite(LedPin,!digitalRead(LedPin));
                              }
                              break;
                              }

                              }

                              //Outputs the data in the ram to the ledstrips
                              void OutputData() {
                              for (int i=0; i<numStrips; i++) {
                              ledStrip.show();
                              }
                              Ack();
                              }

                              //Fills the given area of a ledstrip with a color
                              void Fill() {
                              word firstLed = ReceiveWord();
                              word numberOfLeds = ReceiveWord();
                              int ColorData = ReceiveColorData();
                              if (firstLed <= stripLength * numStrips && numberOfLeds > 0 && firstLed + numberOfLeds – 1 <= stripLength * numStrips) {
                              word endLedNr = firstLed + numberOfLeds;
                              for(word ledNr = firstLed; ledNr < endLedNr; ledNr++) {
                              ledStrip[ledNr / stripLength].setPixelColor(ledNr % stripLength, ColorData);
                              }
                              OutputData();
                              } else {
                              //Number of the first led or the number of leds to receive is outside the allowed range
                              Nack();
                              }
                              }

                              //Receives data for the ledstrips
                              void ReceiveData() {
                              word firstLed = ReceiveWord();

                              word numberOfLeds=ReceiveWord();

                              if( firstLed <= stripLength * numStrips && numberOfLeds > 0 && firstLed + numberOfLeds – 1 <= stripLength * numStrips ) {
                              //FirstLedNr and numberOfLeds are valid.
                              //Receive and set color data

                              word endLedNr = firstLed + numberOfLeds;
                              for(word ledNr = firstLed; ledNr < endLedNr; ledNr++) {
                              ledStrip[ledNr / stripLength].setPixelColor(ledNr % stripLength, ReceiveColorData());
                              }
                              OutputData();
                              } else {
                              Nack(); //Number of the first led or the number of leds to receive is outside the allowed range

                              }
                              }

                              //Sets the length of the longest connected ledstrip. Length is restricted to the max number of allowed leds
                              void SetLedStripLength() {
                              word newStripLength=ReceiveWord();
                              if (newStripLength < 1 || newStripLength > MaxLedsPerStrip) {
                              //stripLength is either to small or above the max number of leds allowed
                              Nack();
                              } else {
                              //stripLength is in the valid range
                              stripLength = newStripLength;
                              for (int i=0; i<numStrips; i++) {
                              ledStrip.updateLength(stripLength);
                              ledStrip.begin();
                              }

                              Ack();
                              }
                              }

                              //Clears the data for all configured leds
                              void ClearAllLedData() {
                              for (word ledNr=0; ledNr < stripLength * numStrips; ledNr++) {
                              ledStrip[ledNr / stripLength].setPixelColor(ledNr % stripLength, 0);
                              }
                              OutputData();
                              }

                              //Sends the firmware version
                              void SendVersion() {
                              Serial.write(FirmwareVersionMajor);
                              Serial.write(FirmwareVersionMinor);
                              Ack();
                              }

                              //Sends the max number of leds per strip
                              void SendMaxNumberOfLeds() {
                              byte B = MaxLedsPerStrip >> 8;
                              Serial.write(B);
                              ledStrip[0].setPixelColor(10, GREEN);
                              ledStrip[0].show();
                              B = MaxLedsPerStrip & 255;
                              Serial.write(B);
                              ledStrip[0].setPixelColor(11, GREEN);
                              ledStrip[0].show();
                              Ack();
                              }

                              //Sends a ack (A)
                              void Ack() {
                              ledStrip[0].setPixelColor(12, GREEN);
                              ledStrip[0].show();
                              Serial.write(‘A’);
                              }

                              //Sends a NACK (N)
                              void Nack() {
                              Serial.write(‘N’);
                              }

                              //Receives 3 bytes of color data.
                              int ReceiveColorData() {
                              while(!Serial.available()) {};
                              int colorValue=Serial.read();
                              while(!Serial.available()) {};
                              colorValue=(colorValue<<8)|Serial.read();
                              while(!Serial.available()) {};
                              colorValue=(colorValue<<8)|Serial.read();

                              return colorValue;

                              }

                              //Receives a word value. High byte first, low byte second
                              word ReceiveWord() {
                              while(!Serial.available()) {};
                              word wordValue=Serial.read()<<8;
                              while(!Serial.available()) {};
                              wordValue=wordValue|Serial.read();

                              return wordValue;
                              }

                              // Colors for testing – assumes WS2812 color order of G, R, B
                              /*
                              #define RED 0x00FF00
                              #define GREEN 0xFF0000
                              #define BLUE 0x0000FF
                              #define YELLOW 0xFFFF00
                              #define PINK 0x10FF88
                              #define ORANGE 0x45FF00
                              #define WHITE 0xFFFFFF
                              #define BLACK 0x000000
                              */

                              // Less intense colors for testing – assumes WS2812 color order of G, R, B
                              #define RED 0x001600
                              #define GREEN 0x160000
                              #define BLUE 0x000016
                              #define YELLOW 0x141000
                              #define PINK 0x001209
                              #define ORANGE 0x041000
                              #define WHITE 0x101010
                              #define BLACK 0x000000

                              void Test() {
                              unsigned int milisecs = 1000; // change them all in 3 seconds
                              // randomLEDlit();
                              Serial.println(“Testing”);
                              // ColorWipe(RED, milisecs);
                              // ColorWipe(GREEN, milisecs);
                              // ColorWipe(BLUE, milisecs);
                              // ColorWipe(YELLOW, milisecs);
                              // ColorWipe(PINK, milisecs);
                              // ColorWipe(ORANGE, milisecs);
                              // ColorWipe(WHITE, milisecs);
                              // ColorWipe(BLACK, milisecs);
                              }

                              void ColorWipe(unsigned long color, unsigned int wait)
                              {
                              for (int ledNr=0; ledNr < stripLength * numStrips; ledNr++) {
                              ledStrip[ledNr / stripLength].setPixelColor(ledNr % stripLength, color);
                              }

                              digitalWrite(LedPin,1);
                              for (int i=0; i<numStrips; i++) {
                              ledStrip.show();
                              }

                              // wait for desginated timeout and then turn off indicator LED
                              delay(wait);
                              digitalWrite(LedPin,0);
                              }

                               

                              I don’t suppose you have any ideas where I’m going wrong here? It would save me tearing out the very little hair I have left :-)

                              Many thanks for all your help it really is very much appreciated :-)

                               

                               

                               

                              #197462
                              2borG
                              Participant
                                @2borg

                                That error doesn’t happen here so I really don’t know whats is causing that. I would check the following

                                1. DirectOut version… Are you using R3++ Grand Unified?

                                2. File permissions. Just change everything to everyone / full  control

                                3. Antivirus… Try disabling

                                4. Unblock files

                                5. Disable User account control?

                                 

                                 

                                 

                                #197472
                                Johnny T
                                Participant
                                  @johnnyt

                                  That error doesn’t happen here so I really don’t know whats is causing that. I would check the following

                                  1. DirectOut version… Are you using R3++ Grand Unified?

                                  2. File permissions. Just change everything to everyone / full control

                                  3. Antivirus… Try disabling

                                  4. Unblock files

                                  5. Disable User account control?

                                  Yep, I’ve checked all that, thanks. I really appreciate you getting back to me on this. I know it’s really difficult trying to diagnose things remotely.

                                  I’ll post my problem in the main forums and see if anyone else can chime in. It’s a weird one. I’ll crack on with the fault finding tomorrow and I’ll post back when (if!!!) I sort it in case anyone else has similar issues.

                                  Thanks again for getting back to me :-)

                                  #212340
                                  FinPerlak
                                  Participant
                                    @finperlak

                                    Hi….It is safe to say that you are utilizing any library for the LED’s, similar to the Adafruit rendition? Carefully, you can address 5 strips with 5 information pins, yet 1500 drove’s out and out might require an excess of information transfer time contrasted with you wanted pace of movement.

                                    I would recommend that you will get past this with far less melancholy in the event that you purchase five Nanos (remains than $3 per) so every one controls a strip. In the event that you need synchronization between them, put a heartbeat yield on one Nano pin, and send it as a sync contribution to the others.

                                    order pcb assembly

                                    #212342
                                    Johnny T
                                    Participant
                                      @johnnyt

                                      Thanks for that. I cracked it in the end after standing on the shoulders of giants (i.e. some other software that I found). I re-wrote it to use the FastLED library and all works brilliantly now.

                                      Thanks for your help.

                                       

                                    Viewing 17 posts - 1 through 17 (of 17 total)

                                    Forums are currently locked.

                                    ©2025 VPinBall.com

                                    Log in with your credentials

                                    Forgot your details?