Advertisement
Guest User

Untitled

a guest
May 20th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | None | 0 0
  1. /*************************************************************************************************************
  2. *
  3. * Title             : Example DMX Receiver
  4. * Version           : v 0.3
  5. * Last updated              : 07.07.2012
  6. * Target            : Arduino mega 2560, Arduino mega 1280, Arduino nano
  7. * Author                    : Toni Merino - merino.toni at gmail.com
  8. * Web                       : www.deskontrol.net/blog
  9. *
  10. **************************************************************************************************************/
  11. #include <lib_dmx.h>  // comment/uncomment #define USE_UARTx in lib_dmx.h as needed
  12. #include <Servo.h>
  13. // This example receive 4 channels from address 1 to 4 and write analog values to PWM pins 2 to 5
  14.  
  15. // outputs update in main loop
  16.  
  17.  
  18. //*********************************************************************************************************
  19. //                        New DMX modes *** EXPERIMENTAL ***
  20. //*********************************************************************************************************
  21. #define    DMX512     (0)    // (250 kbaud - 2 to 512 channels) Standard USITT DMX-512
  22. #define    DMX1024    (1)    // (500 kbaud - 2 to 1024 channels) Completely non standard - TESTED ok
  23. #define    DMX2048    (2)    // (1000 kbaud - 2 to 2048 channels) called by manufacturers DMX1000K, DMX 4x or DMX 1M ???
  24.  
  25. void setup()
  26. {
  27.   ArduinoDmx0.set_control_pin(2);    // Arduino output pin for MAX485 input/output control (connect to MAX485 pins 2-3)
  28.   ArduinoDmx0.set_rx_address(1);      // set rx0 dmx start address
  29.   ArduinoDmx0.set_rx_channels(512);     // number of rx channels
  30.   ArduinoDmx0.init_rx(DMX512);   // starts universe 0 as rx, NEW Parameter DMX mode
  31. }  //end setup()
  32.  
  33. void loop()
  34. {
  35.   //write values from dmx channels 1-4 universe 0 to arduino pwm pins 2-5
  36.   analogWrite(3, ArduinoDmx0.RxBuffer[0]);  //buffers 0 indexed
  37.   analogWrite(5, ArduinoDmx0.RxBuffer[1]);
  38.   analogWrite(6, ArduinoDmx0.RxBuffer[2]);
  39.   analogWrite(9, ArduinoDmx0.RxBuffer[3]);
  40. }  //end loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement