daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SoftwareSerial.h>
  2. #include <DMXSerial.h>
  3.  
  4. SoftwareSerial ESPserial(2, 3); // RX | TX
  5.  
  6. bool onoff;
  7. int bright, bright_tmp = -69;
  8. int saturation, saturation_tmp = -69;
  9. double x, x_tmp = -69;
  10. double y, y_tmp = -69;
  11.  
  12. void setup(void)
  13. {
  14.   DMXSerial.init(DMXReceiver);
  15.   ESPserial.begin(57600);
  16. }
  17.  
  18. void loop(void)
  19. {
  20.   readOnOff();
  21.  
  22.   readBright();
  23.  
  24.   readSaturation();
  25.  
  26.   readColorX();
  27.  
  28.   readColorY();
  29.  
  30.   delay (1000);
  31. }
  32.  
  33.  void readOnOff() {
  34.    //odpalanie
  35.   if (DMXSerial.read(1) == 255)
  36.   {
  37.   onoff = 1;
  38.   ESPserial.write(onoff);
  39.   }
  40.   else
  41.   {
  42.   onoff = 0;
  43.   ESPserial.write(onoff);
  44.   }
  45.  }
  46.  
  47.  void readBright(){
  48.   //jasność
  49.   bright = DMXSerial.read(2);
  50.  
  51.   if( bright != bright_tmp)
  52.   {
  53.     bright_tmp = bright;  
  54.     ESPserial.write(bright);
  55.   }
  56.   else
  57.   {
  58.     ESPserial.write(bright_tmp);
  59.   }
  60.  }
  61.  
  62.  void readSaturation(){
  63.  //nasycenie
  64.      saturation = DMXSerial.read(3);
  65.    
  66. if( saturation != saturation_tmp)
  67.    {
  68.     saturation_tmp = saturation;
  69.  
  70.     ESPserial.write(saturation);
  71.    }
  72.    else
  73.    {
  74.     ESPserial.write(saturation_tmp);
  75.    }
  76.  }
  77.  
  78.  void readColorX(){
  79.      x = DMXSerial.read(4);
  80.    
  81.    if( x != x_tmp)
  82.    {
  83.     x_tmp = x;
  84.  
  85.     ESPserial.write(x);
  86.    }
  87.    else
  88.    {
  89.     ESPserial.write(x_tmp);
  90.    }
  91.  }
  92.  
  93.  void readColorY(){
  94.  y = DMXSerial.read(5);
  95.    
  96.    if( y != y_tmp)
  97.    {
  98.     y_tmp = y;
  99.  
  100.     ESPserial.write(y);
  101.    }
  102.    else
  103.    {
  104.     ESPserial.write(y_tmp);
  105.    }
  106.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top