DMX Receiver/ Servo Driver 4 Channel

Поделиться
HTML-код
  • Опубликовано: 26 авг 2024
  • Demonstrates the Arduino Nano receiving a DMX transmission stream, pulling off four channels, and driving 4 servos. Utilizes the Arduino Library called DMXSerial.

Комментарии • 4

  • @jurriaandevosprojects
    @jurriaandevosprojects Год назад +2

    This is exactly what I'm attempting to build... Would you mind sharing your code? I'll eventually figure it out, but it would save me a bunch of fiddling :-)

  • @paulrichardson1643
    @paulrichardson1643 Год назад

    Hi lightman500
    I'm building a dmx projector shutter with a servo motor and the same RS485 board as you I'm using Arduino uno board could you please share your code with me this is the closest video I've found for what I need to achieve

    • @lightman500
      @lightman500  Год назад

      Here is code...
      /*
      Program Name: DMXSerialRecvServo3.ino
      Date: 9/5/22
      Processor: Nano (not Seeedruino Xiao)
      Status: GOOD
      Desciption: DMX receiver using Nano....and controls 4 servos based on mathertel's orginal code
      DMX Address for this receiver is stipuleted in code below (START CHANNEL)
      DMX input is the Nano's hardware RX pin RX0 (next to TX1 pin)
      NOTE: When uploading code, remove the RX0 wire...
      (Shared port with programmer)...then re-insert after upload.
      PWM pins on Nano are 3,5,6,9,10,11 (6 pins total).
      The 4 servos are connected to Pins 3, 5, 6, 9
      Updates: 9/6/22 BTL Adjusted channel count, added comments
      Updated code with servo control
      9/7/22 BTL Updated for 4 servos...removed LED logic
      Adjusted default servo values to 90
      7/3/23 BTL Updated and cleaned up comments
      */
      // DmxSerial - A hardware supported interface to DMX.
      // DmxSerialRecv.ino: Sample DMX application for retrieving 3 DMX values:
      // Copyright (c) 2011-2015 by Matthias Hertel, www.mathertel.de
      // This work is licensed under a BSD style license. See www.mathertel.de/License.aspx
      // Documentation and samples are available at www.mathertel.de/Arduino
      // 25.07.2011 creation of the DmxSerial library.
      // - - - - -
      #include
      #include
      Servo myservo1; // create servo object to control a servo
      Servo myservo2; // create servo object to control a servo
      Servo myservo3; // create servo object to control a servo
      Servo myservo4; // create servo object to control a servo
      // twelve servo objects can be created on most boards
      // Constants for DMX program
      const int servoPin3 = 3; //Servo pins
      const int servoPin5 = 5;
      const int servoPin6 = 6;
      const int servoPin9 = 9;
      // START CHANNEL: This Example receives the 3 values starting with this channel:
      const int startChannel = 1; //Start channel = 1
      void setup() {
      DMXSerial.init(DMXReceiver); //Initalize DMXReciever (uses hardware RX pin)
      // set some default values
      DMXSerial.write(1, 90); //Default to middle if no packets received
      DMXSerial.write(2, 90);
      DMXSerial.write(3, 90);
      DMXSerial.write(4, 90);
      // enable pwm outputs
      pinMode(servoPin3, OUTPUT); // sets the digital pin as output
      pinMode(servoPin5, OUTPUT);
      pinMode(servoPin6, OUTPUT);
      pinMode(servoPin9, OUTPUT);
      myservo1.attach(servoPin3); //attaches the servo on pin 1 to the servo object
      myservo2.attach(servoPin5); //attaches the servo on pin 1 to the servo object
      myservo3.attach(servoPin6); //attaches the servo on pin 1 to the servo object
      myservo4.attach(servoPin9); //attaches the servo on pin 1 to the servo object
      delay(1000); //Delay for power up and serial monitor
      }
      void loop() {
      // Calculate how long no data bucket was received
      unsigned long lastPacket = DMXSerial.noDataSince();
      if (lastPacket < 5000) { //Check for dead DMX signal
      // read recent DMX values and set pwm levels
      myservo1.write(DMXSerial.read(startChannel)); //Read DMX data Command Servo
      myservo2.write(DMXSerial.read(startChannel + 1)); //Read DMX data Command Servo
      myservo3.write(DMXSerial.read(startChannel + 2)); //Read DMX data Command Servo
      myservo4.write(DMXSerial.read(startChannel + 3)); //Read DMX data Command Servo
      delay(25);
      } else {
      myservo1.write(90); //Command Servo to middle
      myservo2.write(90); //Command Servo to middle
      myservo3.write(90); //Command Servo to middle
      myservo4.write(90); //Command Servo to middle
      } // if
      }
      // End.

    • @paulrichardson1643
      @paulrichardson1643 Год назад

      Hi was waiting on some parts to arrive before I could test it works awesome thanks for all your help and time