Teeces, PSI pulse de Chris Reiff

  • Ce sujet est vide.
14 sujets de 1 à 14 (sur un total de 14)
  • Auteur
    Messages
  • #79236
    Anonyme

      Est-ce que quelqu’un utilise la fonction pulse des PSI de Chris Reiff ? Je l’avais dans mon sketch mais non activé, je l’ai activé pour voir, j’aime bien l’idee mais le rendu est bizarre (surtout quand ça decrease pendant le slide), je ne sais pas trop quelles values bidouiller pour avoir une plus petite amplitude entre le minimum et maximum d’intensité. Il faut que je rematte le film pour voir la fréquence des slides, la fréquences des pulses et leur amplitude pour avoir un truc qui ressemble (même si ça ne sera jamais parfait).

      Voici le code original :

      Code:



      // PULSING PSI LED BRIGHTNESS/INTENSITY
      #if PSIPULSER>0
      int pulseState = LOW; //initial state of our PSI (high intensity, going down)
      int pulseVal = 15; //initial value of our PSI (full intensity)
      void PSIpulse(unsigned long elapsed) {
      static unsigned long timeLast=0;
      if ((elapsed – timeLast) < 100) return; //proceed if 100 milliseconds have passed timeLast = elapsed; if (pulseState == HIGH) { //increase intensity pulseVal++; //increase value by 1 if (pulseVal == 16) { //if we've gone beyond full intensity, start going down again pulseVal = 15; pulseState = LOW; } } else { //decrease intensity pulseVal--; //increase value by 1 if (pulseVal == 0) { //if we've gone beyond full intensity, start going down again pulseVal = 1; pulseState = HIGH; } } #if PSIPULSER==1 || PSIPULSER==3 lcFront.setIntensity(2,pulseVal); //set the front intensity #endif #if PSIPULSER==2 || PSIPULSER==3 lcRear.setIntensity(3,pulseVal); //set the rear intensity #endif } #endif

      #104460
      Anonyme

        C’est pour quelle carte ?

        Si c’est du Arduino il n’y a pas d’appel à une bibliothèque ou le programme n’est pas complet.

        #104461
        Anonyme

          e-fan wrote:

          C’est pour quelle carte ?

          Si c’est du Arduino il n’y a pas d’appel à une bibliothèque ou le programme n’est pas complet.

          C’est pour arduino,

          Voici mon code complet :

          Code:

          // =======================================================================================
          // ============================ Universal Dome Lighting Sketch ===========================
          // =======================================================================================
          // Version : 2012-11-04 (added more PSI options)
          //
          // A sketch to run on an Arduino inside the dome. This runs Teeces lighting.
          //
          // Thrown together by Paul Murphy (JoyMonkey) from various sources including…
          // John V, Michael Erwin, Michael Smith, Roger Moolay, Chris Reiff and Brad Oakley
          //
          // Required : http://arduino.cc/playground/uploads/Main/LedControl.zip
          // (that’s an Arduino Library – it needs to be downloaded and extracted into your
          // Libraries folder for this sketch to work)
          //
          // Logic Display and PSI Boards should be wired up in two chains (to prevent problems that
          // some builders ran into when using a single chain setup for an extended period of time).
          // In early 2012 a revised RLD board was released with two outputs to make wiring up in a
          // two chain setup a little easier.
          // V3.1 OUT2 uses Arduino Pro Micro or Pro Mini pins 9,8,7 for the FLDs and front PSI.
          // If you’re using the older V3 RLD and don’t have the OUT2 pins, don’t panic! You can
          // still wire up a front chain by connecting directly to the Arduino pins.
          //
          // If using a V3 RLD…
          // RLD OUT -> Rear PSI
          // Arduino Pins 9,8,7 -> FLD IN D,C,L -> FLD -> Front PSI
          // (you will also need to supply +5V and GND to the front chain; it can go to any pins
          // labeled +5V and GND on any of the FLD or front PSI boards)
          //
          // If using a V3.1 RLD connections are a little simpler…
          // RLD OUT1 -> Rear PSI
          // RLD OUT2 -> FLD -> FLD -> Front PSI
          //
          // This sketch will work with an Arduino Pro Micro or Pro Mini mounted to the RLD.
          // The Pro Micro uses slightly different pin numbers and has additional small LEDs on it
          // that we can blink back and forth to confirm it’s working (I call this microPSI).
          // Because of these differences this sketch needs to be edited to suit a Pro Micro or a
          // Pro Mini. If using a Pro Mini, simply delete the first line of code below…

          //#define PROMICRO //delete or comment-out this line if you’re not using an Arduino Pro MICRO

          char text[] = “BOOTING999 R28J4 READY”; //PUT YOUR STARTUP TEXT HERE.

          // set brightness levels here (a value of 0-15)…
          int RLDbright=5; //rear Logic
          int RPSIbright=12; //rear PSI
          int FLDbright=5; //front Logics
          int FPSIbright=12; //front PSI

          //delay time of logic display blinkyness (lower = blink faster)
          int LogicBlinkTime=175;

          //set the type of our front and rear PSI’s
          #define PSItype 5
          // 1 = Teeces original (6 LEDs of each color, arranged side by side)
          // 2 = Teeces original checkerboard (6 LEDs of each color arranged in a checkerboard pattern)
          // 3 = Teeces V3.2 PSI by John V (13 LEDs of each color, arranged side by side)
          // 4 = Teeces V3.2 PSI checkerboard by John V (13 LEDs of each color, in a checkerboard pattern)
          // 5 = Teeces V2 FLD converted to PSI with RafkeP’s original pattern

          //set timing of the PSI’s here (in milliseconds)…
          int psiRed=2500; //how long front PSI stays red
          int psiBlue=1700; //how long front PSI stays blue
          int psiYellow=1700; //how long rear PSI stays yellow
          int psiGreen=2500; //how long rear PSI stays green
          int rbSlide=300; // mts – time to transition between red and blue in slide mode
          int ygSlide=300; // mts – time to transition between yellow and green in slide mode

          //pulse the PSI Brightness (0=off, 1=Front, 2=Rear, 3=Both)
          #define PSIPULSER 3

          //#define TESTLOGICS //turns on all logic LEDs at once, useful for troubleshooting

          //#define FLDx4 //for an R7 dome with 4 FLDs (if you have 4 FLDs then delete the first // )

          // Most builders shouldn’t have to edit anything below here. Enjoy!
          //
          // =======================================================================================
          // =======================================================================================

          //for scrolling text on logics…
          int pixelPos=27;
          int scrollCount=0;
          //virtual coords are 5×45; device coords are 3 panels 6×8 each
          unsigned long v_grid[5]; //this will give 5×40 bits

          #include
          #undef round

          #if defined(PROMICRO)
          #define DVAL 14
          #define CVAL 16
          #else
          #define DVAL 12
          #define CVAL 11
          #endif

          #if defined(FLDx4)
          #define FDEV 5 //5 devices for front chain
          #define FPSIDEV 4 //front PSI is device #4 in the chain
          #else
          #define FDEV 3 //3 devices for front chain
          #define FPSIDEV 2 //front PSI is device #2 in the chain
          #endif

          #define RPSIDEV 3 //rear PSI is device #3 in the chain

          //START UP LEDCONTROL…
          LedControl lcRear=LedControl(DVAL,CVAL,10,4); //rear chain (Pro Mini/Pro Micro pins)
          LedControl lcFront=LedControl(9,8,7,FDEV); //front chain

          // =======================================================================================
          #if (PSItype==5) // slide animation code for RafkeP original pattern PSI boards (code by RafkeP)
          //#define HPROW 5
          class PSI {
          int stage; //0 thru 9
          int inc;
          int stageDelay[10];
          int cols[10][6];
          int randNumber; //a random number to decide the fate of the last stage

          unsigned long timeLast;
          int device;

          public:

          PSI(int _delay1, int _delay2, int _delay3, int _device)
          {
          device=_device;

          stage=0;
          timeLast=0;
          inc=1;

          cols[0][0] = B01010101;
          cols[0][1] = B10101010;
          cols[0][2] = B01010101;
          cols[0][3] = B10101010;
          cols[0][4] = B01010101;
          cols[0][5] = B01010000;

          cols[1][0] = B11010101;
          cols[1][1] = B00101010;
          cols[1][2] = B11010101;
          cols[1][3] = B00101010;
          cols[1][4] = B11010101;
          cols[1][5] = B01010000;

          cols[2][0] = B10010101;
          cols[2][1] = B01101010;
          cols[2][2] = B10010101;
          cols[2][3] = B01101010;
          cols[2][4] = B10010101;
          cols[2][5] = B01010000;

          cols[3][0] = B10110101;
          cols[3][1] = B01001010;
          cols[3][2] = B10110101;
          cols[3][3] = B01001010;
          cols[3][4] = B10110101;
          cols[3][5] = B01010000;

          cols[4][0] = B10100101;
          cols[4][1] = B01011010;
          cols[4][2] = B10100101;
          cols[4][3] = B01011010;
          cols[4][4] = B10100101;
          cols[4][5] = B01010000;

          cols[5][0] = B10101101;
          cols[5][1] = B01010010;
          cols[5][2] = B10101101;
          cols[5][3] = B01010010;
          cols[5][4] = B10101101;
          cols[5][5] = B01010000;

          cols[6][0] = B10101001;
          cols[6][1] = B01010110;
          cols[6][2] = B10101001;
          cols[6][3] = B01010110;
          cols[6][4] = B10101001;
          cols[6][5] = B01010000;

          cols[7][0] = B10101011;
          cols[7][1] = B01010100;
          cols[7][2] = B10101011;
          cols[7][3] = B01010100;
          cols[7][4] = B10101011;
          cols[7][5] = B01010000;

          cols[8][0] = B10101010;
          cols[8][1] = B01010101;
          cols[8][2] = B10101010;
          cols[8][3] = B01010101;
          cols[8][4] = B10101010;
          cols[8][5] = B01010000;

          cols[9][0] = B10101010;
          cols[9][1] = B01010101;
          cols[9][2] = B10101010;
          cols[9][3] = B01010101;
          cols[9][4] = B10101010;
          cols[9][5] = B10101000;

          stageDelay[0] = _delay1 – _delay3;
          stageDelay[1] = _delay3/8;
          stageDelay[2] = _delay3/8;
          stageDelay[3] = _delay3/8;
          stageDelay[4] = _delay3/8;
          stageDelay[5] = _delay3/8;
          stageDelay[6] = _delay3/8;
          stageDelay[7] = _delay3/8;
          stageDelay[8] = _delay3/8;
          stageDelay[9] = _delay2 – _delay3;
          }

          void Animate(unsigned long elapsed, LedControl control)
          {
          if ((elapsed – timeLast) < stageDelay[stage]) return; timeLast = elapsed; stage+=inc; if (stage>9 || stage<0 )
          {
          inc *= -1;
          stage+=inc*2;
          }
          /*
          if (stage==6) //randomly choose whether or not to go 'stuck'
          {
          randNumber = random(9);
          if (randNumber<5) { //set the last stage to 'stuck'
          cols[6][0] = B01010000;
          cols[6][1] = B10101100;
          cols[6][2] = B01010000;
          cols[6][3] = B10101100;
          cols[6][4] = B01010000;
          }
          else //reset the last stage to a solid color
          {
          cols[6][0] = B01010100;
          cols[6][1] = B10101000;
          cols[6][2] = B01010100;
          cols[6][3] = B10101000;
          cols[6][4] = B01010100;
          }
          }
          if (stage==0) //randomly choose whether or not to go 'stuck'
          {
          randNumber = random(9);
          if (randNumber<5) { //set the first stage to 'stuck'
          cols[0][0] = B00101000; //R B R B R B
          cols[0][1] = B11010100; //B R B R B R
          cols[0][2] = B00101000; //R B R B R B
          cols[0][3] = B11010100; //B R B R B R
          cols[0][4] = B00101000; //R B R B R B
          }
          else //reset the first stage to a solid color
          {
          cols[0][0] = B10101000;
          cols[0][1] = B01010100;
          cols[0][2] = B10101000;
          cols[0][3] = B01010100;
          cols[0][4] = B10101000;
          }
          }
          */
          for (int row=0; row<6; row++)
          control.setRow(device,row,cols[stage][row]);
          }
          };

          #endif

          // =======================================================================================
          #if (PSItype==4) // slide animation code for Teeces V2 PSI boards (code by John V)
          #define HPROW 5
          class PSI {
          int stage; //0 thru 6
          int inc;
          int stageDelay[7];
          int cols[7][5];
          int randNumber; //a random number to decide the fate of the last stage

          unsigned long timeLast;
          int device;

          public:

          PSI(int _delay1, int _delay2, int _delay3, int _device)
          {
          device=_device;

          stage=0;
          timeLast=0;
          inc=1;

          cols[0][0] = B10101000;
          cols[0][1] = B01010100;
          cols[0][2] = B10101000;
          cols[0][3] = B01010100;
          cols[0][4] = B10101000;

          cols[1][0] = B00101000; //R B R B R B
          cols[1][1] = B11010100; //B R B R B R
          cols[1][2] = B00101000; //R B R B R B
          cols[1][3] = B11010100; //B R B R B R
          cols[1][4] = B00101000; //R B R B R B

          cols[2][0] = B01101000;
          cols[2][1] = B10010100;
          cols[2][2] = B01101000;
          cols[2][3] = B10010100;
          cols[2][4] = B01101000;

          cols[3][0] = B01001000;
          cols[3][1] = B10110100;
          cols[3][2] = B01001000;
          cols[3][3] = B10110100;
          cols[3][4] = B01001000;

          cols[4][0] = B01011000;
          cols[4][1] = B10100100;
          cols[4][2] = B01011000;
          cols[4][3] = B10100100;
          cols[4][4] = B01011000;

          cols[5][0] = B01010000;
          cols[5][1] = B10101100;
          cols[5][2] = B01010000;
          cols[5][3] = B10101100;
          cols[5][4] = B01010000;

          cols[6][0] = B01010100;
          cols[6][1] = B10101000;
          cols[6][2] = B01010100;
          cols[6][3] = B10101000;
          cols[6][4] = B01010100;

          stageDelay[0] = _delay1 - _delay3;
          stageDelay[1] = _delay3/5;
          stageDelay[2] = _delay3/5;
          stageDelay[3] = _delay3/5;
          stageDelay[4] = _delay3/5;
          stageDelay[5] = _delay3/5;
          stageDelay[6] = _delay2 - _delay3;
          }

          void Animate(unsigned long elapsed, LedControl control)
          {
          if ((elapsed - timeLast) < stageDelay[stage]) return; timeLast = elapsed; stage+=inc; if (stage>6 || stage<0 )
          {
          inc *= -1;
          stage+=inc*2;
          }

          if (stage==6) //randomly choose whether or not to go 'stuck'
          {
          randNumber = random(9);
          if (randNumber<5) { //set the last stage to 'stuck'
          cols[6][0] = B01010000;
          cols[6][1] = B10101100;
          cols[6][2] = B01010000;
          cols[6][3] = B10101100;
          cols[6][4] = B01010000;
          }
          else //reset the last stage to a solid color
          {
          cols[6][0] = B01010100;
          cols[6][1] = B10101000;
          cols[6][2] = B01010100;
          cols[6][3] = B10101000;
          cols[6][4] = B01010100;
          }
          }
          if (stage==0) //randomly choose whether or not to go 'stuck'
          {
          randNumber = random(9);
          if (randNumber<5) { //set the first stage to 'stuck'
          cols[0][0] = B00101000; //R B R B R B
          cols[0][1] = B11010100; //B R B R B R
          cols[0][2] = B00101000; //R B R B R B
          cols[0][3] = B11010100; //B R B R B R
          cols[0][4] = B00101000; //R B R B R B
          }
          else //reset the first stage to a solid color
          {
          cols[0][0] = B10101000;
          cols[0][1] = B01010100;
          cols[0][2] = B10101000;
          cols[0][3] = B01010100;
          cols[0][4] = B10101000;
          }
          }

          for (int row=0; row<5; row++)
          control.setRow(device,row,cols[stage][row]);
          }
          };

          #endif

          // =======================================================================================
          #if (PSItype==3) // slide animation code for Teeces V2 PSI boards (code by John V)
          #define HPROW 5
          class PSI {
          int stage; //0 thru 6
          int inc;
          int stageDelay[7];
          int cols[7];

          unsigned long timeLast;
          int device;

          public:

          PSI(int _delay1, int _delay2, int _delay3, int _device)
          {
          device=_device;

          stage=0;
          timeLast=0;
          inc=1;

          cols[0] = B11100000;
          cols[1] = B11110000;
          cols[2] = B01110000;
          cols[3] = B01111000;
          cols[4] = B00111000;
          cols[5] = B00111100;
          cols[6] = B00011100;

          stageDelay[0] = _delay1 - _delay3;
          stageDelay[1] = _delay3/5;
          stageDelay[2] = _delay3/5;
          stageDelay[3] = _delay3/5;
          stageDelay[4] = _delay3/5;
          stageDelay[5] = _delay3/5;
          stageDelay[6] = _delay2 - _delay3;
          }
          void Animate(unsigned long elapsed, LedControl control)
          {
          if ((elapsed - timeLast) < stageDelay[stage]) return; timeLast = elapsed; stage+=inc; if (stage>6 || stage<0 )
          {
          inc *= -1;
          stage+=inc*2;
          }

          for (int row=0; row<5; row++)
          control.setRow(device,row,cols[stage]);
          }
          };
          #endif
          // =======================================================================================
          //michael smith's checkerboard PSI method for Teeces original PSI boards
          // Michael's original sketch is here : http://pastebin.com/hXeZb7Gd
          #if (PSItype==2)
          #define HPROW 4
          static const int patternAtStage[] = { B01010000, B11010000, B10010000, B10110000, B10100000, B00100000, B01100000, B01000000, B01010000 };
          class PSI
          {
          bool state;
          int stage;
          unsigned long timeLast;
          int delay1, delay2, delay3;
          int device;
          int delayAtStage[9];
          int slideDirection; // is either 1 or -1
          int maxStage; // for PSIslide it's either 5 or 9 stages, for traditional PSI it's just back and forth between 2
          public:
          PSI(int _delay1, int _delay2, int _delay3, int _device)
          {
          delayAtStage[0] = _delay1;
          delayAtStage[1] = _delay3/3; // delay3 is total transition time - divide it by the 3 stages of transition
          delayAtStage[2] = delayAtStage[1];
          delayAtStage[3] = delayAtStage[1];
          delayAtStage[4] = _delay2;
          delayAtStage[5] = delayAtStage[1];
          delayAtStage[6] = delayAtStage[1];
          delayAtStage[7] = delayAtStage[1];
          delayAtStage[8] = _delay1; // repeated because it's not a loop it cycles back and forth across the pattern.
          stage=0;
          slideDirection=1;
          maxStage=8; // change to 5 would skip the LtoR from blue to red.
          timeLast=0;
          device=_device;
          // legacy for traditional PSI animation
          delay1=_delay1;
          delay2=_delay2;
          delay3=_delay3;
          state=false;
          }
          void Animate(unsigned long timeNow, LedControl control)
          {
          if ((timeNow - timeLast) < delayAtStage[stage]) return; //Serial.begin(9600); //Serial.println(stage); //Serial.println(patternAtStage[stage]); timeLast = timeNow; stage+=slideDirection; //move to the next stage, which could be up or down in the array if (stage >= maxStage)
          {
          // limit the stage to the maxStage and reverse the direction of the slide
          stage=maxStage;
          slideDirection = -1;
          }
          else if (stage <= 0) { stage=0; slideDirection = 1; } // set the patterns for this stage control.setRow(device,0,patternAtStage[stage]); control.setRow(device,1,~patternAtStage[stage]); control.setRow(device,2,patternAtStage[stage]); control.setRow(device,3,~patternAtStage[stage]); } }; #endif // ======================================================================================= // slide animation code for Teeces original PSI boards #if (PSItype==1) #define HPROW 4 class PSI { int stage; //0 thru 4 int inc; int stageDelay[5]; int cols[5]; unsigned long timeLast; int device; public: PSI(int _delay1, int _delay2, int _device) { device=_device; stage=0; timeLast=0; inc=1; cols[0] = B11000000; cols[1] = B11100000; cols[2] = B01100000; cols[3] = B01110000; cols[4] = B00110000; stageDelay[0] = _delay1 - 300; stageDelay[1] = 100; stageDelay[2] = 100; stageDelay[3] = 100; stageDelay[4] = _delay2 - 300; } void Animate(unsigned long elapsed, LedControl control) { if ((elapsed - timeLast) < stageDelay[stage]) return; timeLast = elapsed; stage+=inc; if (stage>4 || stage<0 ) {
          inc *= -1;
          stage+=inc*2;
          }
          for (int row=0; row<4; row++) control.setRow(device,row,cols[stage]);
          }
          };
          #endif
          // =======================================================================================
          #if (PSItype==1)
          PSI psiFront=PSI(psiRed, psiBlue, FPSIDEV); // device is FPSIDEV (#2 or #4 for an R7 dome)
          PSI psiRear =PSI(psiYellow, psiGreen, RPSIDEV); // device is #3
          //#endif
          //#if (PSItype==2) || (PSItype==3)
          #else
          PSI psiFront=PSI(psiRed, psiBlue, rbSlide, FPSIDEV); //2000 ms on red, 1000 ms on blue.
          PSI psiRear =PSI(psiYellow, psiGreen, ygSlide, RPSIDEV); //1000 ms on yellow, 2000 ms on green.
          #endif
          // =======================================================================================
          void setup() {
          Serial.begin(9600); //used for debugging
          for(int dev=0;dev0
          PSIpulse(timeNew);
          #endif
          }
          // =======================================================================================
          // this is the code to blink all the logic LEDs randomly…
          void animateLogic(unsigned long elapsed) {
          static unsigned long timeLast=0;
          if ((elapsed – timeLast) < LogicBlinkTime) return; timeLast = elapsed; #if defined(TESTLOGICS) //turn on all logic LEDs to make sure they're all working for (int dev=0; dev<3; dev++) for (int row=0; row<6; row++) lcRear.setRow(dev,row,255); for (int dev=0; dev0
          int pulseState = LOW; //initial state of our PSI (high intensity, going down)
          int pulseVal = 15; //initial value of our PSI (full intensity)
          void PSIpulse(unsigned long elapsed) {
          static unsigned long timeLast=0;
          if ((elapsed – timeLast) < 100) return; //proceed if 100 milliseconds have passed timeLast = elapsed; if (pulseState == HIGH) { //increase intensity pulseVal++; //increase value by 1 if (pulseVal == 16) { //if we've gone beyond full intensity, start going down again pulseVal = 15; pulseState = LOW; } } else { //decrease intensity pulseVal--; //increase value by 1 if (pulseVal == 0) { //if we've gone beyond full intensity, start going down again pulseVal = 1; pulseState = HIGH; } } #if PSIPULSER==1 || PSIPULSER==3 lcFront.setIntensity(2,pulseVal); //set the front intensity #endif #if PSIPULSER==2 || PSIPULSER==3 lcRear.setIntensity(3,pulseVal); //set the rear intensity #endif } #endif //////////////////////////////////// // ======================================================================================= // AUREBESH CHARACTERS TAKEN FROM MOOLAY'S SKETCH // http://astromech.net/forums/showthread.php?p=99487 void showGrid() { //copy from virt coords to device coords unsigned char col8=0; unsigned char col17=0; unsigned char col26=0; for (int row=0; row<5; row++) { lcRear.setRow(0,row, rev( v_grid[row] & 255L ) ); //device 0 lcRear.setRow(1,row, rev( (v_grid[row] & 255L<<9) >> 9 ) ); //device 1
          lcRear.setRow(2,row, rev( (v_grid[row] & 255L<<18) >> 18 ) ); //device 2
          lcFront.setRow(0,row, rev( v_grid[row] & 255L ) ); //device 0
          lcFront.setRow(1,row, rev( (v_grid[row] & 255L<<9) >> 9 ) ); //device 1
          if ( (v_grid[row] & 1L<<8) == 1L<<8) col8 += 128>>row;
          if ( (v_grid[row] & 1L<<17) == 1L<<17) col17 += 128>>row;
          if ( (v_grid[row] & 1L<<26) == 1L<<26) col26 += 128>>row;
          }
          lcRear.setRow(0, 5, col8);
          lcRear.setRow(1, 5, col17);
          lcRear.setRow(2, 5, col26);
          lcFront.setRow(0, 5, col8);
          lcFront.setRow(1, 5, col17);
          }
          unsigned char rev(unsigned char b) {
          //reverse bits of a byte
          return (b * 0x0202020202ULL & 0x010884422010ULL) % 1023;
          }
          void initGrid() {
          for (int row=0; row<6; row++) v_grid[row]=0L;
          }
          int c9[] = {
          B00000000,
          B00000000,
          B00000000,
          B00000000,
          B00000100 };
          int c8[] = {
          B00000000,
          B00000000,
          B00001111,
          B00000000,
          B00000000 };
          int c4[] = {
          B00001001,
          B00001001,
          B00001111,
          B00001000,
          B00001000 };
          int c2[] = {
          B00001111,
          B00001000,
          B00001111,
          B00000001,
          B00001111 };
          int cA[] = { B00000110,
          B00001001,
          B00001111,
          B00001001,
          B00001001 };

          int cB[] = { B00000111,
          B00001001,
          B00000111,
          B00001001,
          B00000111 };

          int cC[] = { B00000110,
          B00001001,
          B00000001,
          B00001001,
          B00000110 };

          int cD[] = { B0000111,
          B0001001,
          B0001001,
          B0001001,
          B0000111 };

          int cE[] = { B00001111,
          B00000001,
          B00000111,
          B00000001,
          B00001111 };

          int cF[] = { B00001111,
          B00000001,
          B00000111,
          B00000001,
          B00000001 };

          int cG[] = { B00001110,
          B00000001,
          B00001101,
          B00001001,
          B00000110 };

          int cH[] = { B00001001,
          B00001001,
          B00001111,
          B00001001,
          B00001001 };

          int cI[] = { B00000111,
          B00000010,
          B00000010,
          B00000010,
          B00000111 };

          int cJ[] = { B00001000,
          B00001000,
          B00001000,
          B00001001,
          B00000110 };

          int cK[] = { B00001001,
          B00000101,
          B00000011,
          B00000101,
          B00001001 };

          int cL[] = { B00000001,
          B00000001,
          B00000001,
          B00000001,
          B00001111 };

          int cM[] = { B00010001,
          B00011011,
          B00010101,
          B00010001,
          B00010001 };

          int cN[] = { B00001001,
          B00001011,
          B00001101,
          B00001001,
          B00001001 };

          int cO[] = { B00000110,
          B00001001,
          B00001001,
          B00001001,
          B00000110 };

          int cP[] = { B00000111,
          B00001001,
          B00000111,
          B00000001,
          B00000001 };

          int cQ[] = { B00000110,
          B00001001,
          B00001101,
          B00001001,
          B00010110 };

          int cR[] = { B00000111,
          B00001001,
          B00000111,
          B00000101,
          B00001001 };

          int cS[] = { B00001110,
          B00000001,
          B00000110,
          B00001000,
          B00000111 };

          int cT[] = { B00011111,
          B00000100,
          B00000100,
          B00000100,
          B00000100 };

          int cU[] = { B00001001,
          B00001001,
          B00001001,
          B00001001,
          B00000110 };

          int cV[] = { B00010001,
          B00010001,
          B00010001,
          B00001010,
          B00000100 };

          int cW[] = { B00010001,
          B00010001,
          B00010001,
          B00010101,
          B00011011 };

          int cX[] = { B00010001,
          B00001010,
          B00000100,
          B00001010,
          B00010001 };

          int cY[] = { B00010001,
          B00010001,
          B00001010,
          B00000100,
          B00000100 };

          int cZ[] = { B00011111,
          B00001000,
          B00000100,
          B00000010,
          B00011111 };
          int cZZ[] = {
          B00000000,
          B00000000,
          B00000000,
          B00000000,
          B00000000 };
          int co[] = {
          B01010101,
          B01010101,
          B01010101,
          B01010101,
          B01010101 };
          void drawLetter(char let, int shift) {
          int *pLetter;
          switch (let) {
          case '9': pLetter=c9; break;
          case '8': pLetter=c8; break;
          case '4': pLetter=c4; break;
          case '2': pLetter=c2; break;
          case 'A': pLetter=cA; break;
          case 'B': pLetter=cB; break;
          case 'C': pLetter=cC; break;
          case 'D': pLetter=cD; break;
          case 'E': pLetter=cE; break;
          case 'F': pLetter=cF; break;
          case 'G': pLetter=cG; break;
          case 'H': pLetter=cH; break;
          case 'I': pLetter=cI; break;
          case 'J': pLetter=cJ; break;
          case 'K': pLetter=cK; break;
          case 'L': pLetter=cL; break;
          case 'M': pLetter=cM; break;
          case 'N': pLetter=cN; break;
          case 'O': pLetter=cO; break;
          case 'P': pLetter=cP; break;
          case 'Q': pLetter=cQ; break;
          case 'R': pLetter=cR; break;
          case 'S': pLetter=cS; break;
          case 'T': pLetter=cT; break;
          case 'U': pLetter=cU; break;
          case 'V': pLetter=cV; break;
          case 'W': pLetter=cW; break;
          case 'X': pLetter=cX; break;
          case 'Y': pLetter=cY; break;
          case 'Z': pLetter=cZ; break;
          case '_': pLetter=cZZ; break;
          default:return;
          }
          //loop thru rows of the letter
          for (int i=0; i<5; i++) {
          if (shift>0) //positive shift means letter is slid to the right on the display
          v_grid[i] += (long)pLetter[i] << shift; else //negative shift means letter is slid to the left so that only part of it is visible v_grid[i] += (long)pLetter[i] >> -shift;
          }
          }
          void scrollingText() {
          for (int i=0; i

          #104459
          Anonyme

            Bon j’ai joué un peu avec les valeurs, j’arrive à modifier la fréquence de la pulsation, mais pas l’amplitude (juste l’intensité des LEDS) j’aimerais un effet plus subtile entre l’intensité la plus faible et la plus forte, mais bon je ne sais pas si c’est possible.

            #104462
            Anonyme

              Voici la partie qui gère les temps,les quatre premières gèrent la durée de la couleur et les deux dernières ligne gèrent le temps de transition–

              essayes en variant les valeurs de 50 (une à la fois pour voir l’effet)

              //set timing of the PSI’s here (in milliseconds)…

              int psiRed=2500; //how long front PSI stays red

              int psiBlue=1700; //how long front PSI stays blue

              int psiYellow=1700; //how long rear PSI stays yellow

              int psiGreen=2500; //how long rear PSI stays green

              int rbSlide=300; // mts – time to transition between red and blue in slide mode

              int ygSlide=300; // mts – time to transition between yellow and green in slide mode

              L’intensité de la lumière

              // set brightness levels here (a value of 0-15)…

              int RLDbright=5; //rear Logic

              int RPSIbright=12; //rear PSI

              int FLDbright=5; //front Logics

              int FPSIbright=12; //front PSI

              Le programme limite l’intensité de des LED à 15.

              if (pulseVal == 16) { //if we’ve gone beyond full intensity, start going down again

              pulseVal = 15;

              Cette ligne dans la boucle (loop) le vérifie et la ramène à 15 maximum donc ne pas toucher cette ligne pour éviter ça 😮 😥 .

              le programme est prévu pour soit une carte Pro micro ou pro mini. avec des adaptations à effectuer suivant la carte, elles sont indiquées dans les commentaires.

              C’est juste une analyse rapide du programme

              Il y a une grande partie qui définie les séquences des leds mais je ne suis pas encore arrivé à ce point de la réalisation du R2. il y a aussi une temporisation mais je ne trouve pas son initialisation.

              #104463
              Anonyme

                Si je comprend bien… ce que tu veux faire, c’est réduire l’écart entre l’intensité basse et haute du pulse?

                Va dans la partie du programme qui gère les pulses, ça commence par ça:

                // =======================================================================================

                // PULSING PSI LED BRIGHTNESS/INTENSITY

                #if PSIPULSER>0

                int pulseState = LOW; //initial state of our PSI (high intensity, going down)

                int pulseVal = 15; //initial value of our PSI (full intensity)

                si tu veux aller moins haut en intensité tu commences par changer la valeur initiale de 15 par une valeur moins importante, par exemple :

                int pulseVal = 10; //initial value of our PSI (2/3 intensity)

                Mais c’est un peu plus bas que le pulse est géré:

                if (pulseState == HIGH) { //increase intensity

                pulseVal++; //increase value by 1

                if (pulseVal == 16) { //if we’ve gone beyond full intensity, start going down again

                pulseVal = 15;

                pulseState = LOW;

                }

                }

                else { //decrease intensity

                pulseVal–; //increase value by 1

                if (pulseVal == 0) { //if we’ve gone beyond full intensity, start going down again

                pulseVal = 1;

                pulseState = HIGH;

                }

                Tu pourrais remplacer par :

                if (pulseState == HIGH) { //increase intensity

                pulseVal++; //increase value by 1

                if (pulseVal >10) { //if we’ve gone beyond 2/3 intensity, start going down again

                pulseVal = 10;

                pulseState = LOW;

                }

                }

                else { //decrease intensity

                pulseVal–; //increase value by 1

                if (pulseVal < 6) { //if we've gone beyond 1/3 intensity, start going up again pulseVal = 6; pulseState = HIGH; }

                Ca devrait faire des pulses entre 6 et 10 au lieu de les faire entre 0 et 15.

                Tu peux tester ce que tu voudra comme valeurs au lieu de 6 et 10 mais faut juste bien faire attention de changer toutes les valeurs de manière cohérente comme dans l’exemple ci-dessus.

                #104464
                Anonyme

                  Tu peut modifié la valeur en rouge de cette partie du programme en replaçant par exemple par 5 cela devrait limité la variation de l’intensité de la LED. Mais ne pas dépassé la valeur 14. Mettre la valeur en rouge + 1 dans la valeur en vert

                  Dans ce cas les LED ne seront jamais complétement éteintes

                  else { //decrease intensity

                  pulseVal–; //increase value by 1

                  if (pulseVal == 0) { //if we’ve gone beyond full intensity, start going down again

                  pulseVal = 1;

                  pulseState = HIGH;

                  J’espère que je suis clair 🙁

                  #104465
                  Anonyme

                    Merci les gars ! C’est bien clair, je modifiais bien cette partie (j’ai eu des résultats intéressants mais pas ce que je voulais) mais je ne mettais pas des valeurs de manière cohérente, je vais voir (après le match ;)) en changeant comme vous m’avez indiqué.

                    Une autre chose que j’ai noté mais ce n’est peut-être qu’une sensation, quand l’intensité baisse de la valeur la plus forte à la moins forte ça se fait progressivement mais quand ça passe de la plus petite intensité à la plus importante, d’un coup, pas du tout de manière progressive.

                    #104466
                    Anonyme

                      Merci beaucoup les gars ! Grâce à vous j’ai trouvé un réglage qui me plaît et qui correspond à l’idée que j’avais en tête (mais il faut quand même que je regarde les films, surtout pour la fréquence des pulsations).

                      Ca donne un côté organique au dôme, on dirait un peu un battement de coeur ou de veine ! :)

                      Voici ce que j’ai mis pour le moment pour cette partie de code :

                      Code:


                      // PULSING PSI LED BRIGHTNESS/INTENSITY
                      #if PSIPULSER>0
                      int pulseState = LOW; //initial state of our PSI (high intensity, going down)
                      int pulseVal = 15; //initial value of our PSI (full intensity)
                      void PSIpulse(unsigned long elapsed) {
                      static unsigned long timeLast=0;
                      if ((elapsed – timeLast) < 115) return; //proceed if 100 milliseconds have passed timeLast = elapsed; if (pulseState == HIGH) { //increase intensity pulseVal++; //increase value by 1 if (pulseVal == 10) { //if we've gone beyond full intensity, start going down again pulseVal = 10; pulseState = LOW; } } else { //decrease intensity pulseVal--; //increase value by 1 if (pulseVal == 6) { //if we've gone beyond full intensity, start going down again pulseVal = 7; pulseState = HIGH; } } #if PSIPULSER==1 || PSIPULSER==3 lcFront.setIntensity(2,pulseVal); //set the front intensity #endif #if PSIPULSER==2 || PSIPULSER==3 lcRear.setIntensity(3,pulseVal); //set the rear intensity #endif } #endif ////////////////////////////////////

                      Merci encore pour votre aide, le résultat est très bon ! J’ai une autre question, mais ce sera pour plus tard (sur comment bloqué aléatoirement les PSI sur une couleur ou mi rouge-mi bleu voir même bleu avec un chouïa de rouge dans un coin de temps en temps quand la color wheel était bloquée ! :)).

                      #104467
                      Anonyme

                        MonsieurTox wrote:

                        Ca donne un côté organique au dôme, on dirait un peu un battement de coeur ou de veine !


                        Cool que ça te plaise.

                        Il y a une autre variable avec laquelle tu pourrais jouer pour améliorer “le côté organique”: c’est la fréquence des pulsations.

                        Elle est fixe dans ce programme mais on pourrait la rendre variable selon l’humeur du droïde, ou selon que les pulsations sont montantes ou descendantes ou bien encore juste y mettre un peu d’aléatoire: c’est dingue ce que ça change quand on met un peu de variations “naturelles” : ça rend l’ensemble beaucoup plus “vivant” !

                        #104468
                        Anonyme

                          Ah oui ce serait une bonne idée, une fréquence plus élevée quand il est en mode bad mood avec le PSI tout rouge !

                          #104469
                          Anonyme

                            J’ai une autre question, comment fait-on pour merger 2 sketches sans qu’il n’y ait de conflits ?

                            J’ai ce code (pour les holos) :

                            Code:

                            /*
                            * SARLACC For Holo Projectors v 0.3a
                            *
                            * – Simple
                            * – Arduino
                            * – Random Holoprojector
                            * – Location for
                            * – AstroMech Builders
                            * – Club
                            * – Control
                            *
                            * Micke Askernäs, 2012
                            *
                            */

                            #include

                            /*
                            * User defined constants
                            * change these for finetuning your servos
                            * *NOTE* These values are set for my servos.
                            * In order to get your system running smooth, you need to
                            * set your own values. See test code at the bottom of code.
                            */

                            const int Min1X = 45; // Min value for X1
                            const int Max1X = 150; // Max value for X1
                            const int Min1Y = 0; // Min value for Y1
                            const int Max1Y = 130; // Max value for Y1

                            const int Min2X = 20; // Min value for X2
                            const int Max2X = 150; // Max value for X2
                            const int Min2Y = 45; // Min value for Y2
                            const int Max2Y = 160; // Max value for Y2

                            const int Min3X = 0; // Min value for X3
                            const int Max3X = 180; // Max value for X3
                            const int Min3Y = 40; // Min value for Y3
                            const int Max3Y = 170; // Max value for Y3

                            const int MinTime = 1000; // Minimum time to wait before another servo movement.
                            const int MaxTime = 6000; // Maximum time to wait before another servo movement.

                            /*
                            * Arduino Pin Configuration
                            * Change these if needed
                            */

                            const int servo1Xpin = 8; // PIN on Arduino used for Servo1X
                            const int servo1Ypin = 9; // PIN on Arduino used for Servo1Y
                            const int servo2Xpin = 10; // PIN on Arduino used for Servo2X
                            const int servo2Ypin = 11; // PIN on Arduino used for Servo2Y
                            const int servo3Xpin = 12; // PIN on Arduino used for Servo3X
                            const int servo3Ypin = 13; // PIN on Arduino used for Servo3Y

                            /*
                            * End Arduino Pin Configuration
                            */

                            /*
                            * End constants
                            */

                            /* No more changes should be needed below this line. */

                            Servo servo1X; // Define X-Servo 1 (Front)
                            Servo servo1Y; // Define Y-Servo 1 (Front)
                            Servo servo2X; // Define X-Servo 2 (Top)
                            Servo servo2Y; // Define Y-Servo 2 (Top)
                            Servo servo3X; // Define X-Servo 3 (Back)
                            Servo servo3Y; // Define Y-Servo 3 (Back)
                            unsigned long currentTime;
                            unsigned long loopTime;

                            void setup()
                            {
                            servo1X.attach(servo1Xpin); // Attaching servo to defined pin.
                            servo1Y.attach(servo1Ypin); // Attaching servo to defined pin.
                            servo2X.attach(servo2Xpin); // Attaching servo to defined pin.
                            servo2Y.attach(servo2Ypin); // Attaching servo to defined pin.
                            servo3X.attach(servo3Xpin); // Attaching servo to defined pin.
                            servo3Y.attach(servo3Ypin); // Attaching servo to defined pin.

                            randomSeed(analogRead(0)); // Feed unhooked analog input as seed for randomizer. Can be set to static number.
                            // randomSeed(3141592653); // Static number random Seed (for explanantion only)

                            currentTime = millis();
                            loopTime = currentTime;
                            }

                            void loop()
                            {
                            currentTime = millis();

                            /* Loop 1 for Servo1 */
                            if (currentTime >= (loopTime + random(MinTime,MaxTime))) {
                            servo1X.write(random(Min1X,Max1X)); // Turn X-Servo to random X value (0-180)
                            servo1Y.write(random(Min1Y,Max1Y)); // Turn Y-Servo to random X value (0-180)
                            loopTime = currentTime;
                            }

                            /* Loop 2 for Servo2 */
                            if (currentTime >= (loopTime + random(MinTime,MaxTime))) {
                            servo2X.write(random(Min2X,Max2X)); // Turn X-Servo to random X value (0-180)
                            servo2Y.write(random(Min2Y,Max2Y)); // Turn Y-Servo to random X value (0-180)
                            loopTime = currentTime;
                            }

                            /* Loop 3 for Servo3 */
                            if (currentTime >= (loopTime + random(MinTime,MaxTime))) {
                            servo3X.write(random(Min3X,Max3X)); // Turn X-Servo to random X value (0-180)
                            servo3Y.write(random(Min3Y,Max3Y)); // Turn Y-Servo to random X value (0-180)
                            loopTime = currentTime;
                            }

                            /*
                            * Loop for testing max and min values – Comment this out or remove for working program
                            * Recommended to take one servo at the time and test out the min/max values on X first, then Y
                            * and then move on to next servo.
                            */

                            // servo1X.write(Min1X); // Turn Servo 1 to Min X value
                            // servo2X.write(Min2X); // Turn Servo 2 to Min X value
                            // servo3X.write(Min3X); // Turn Servo 3 to Min X value
                            //
                            // servo1Y.write(Min1Y); // Turn Servo 1 to Min Y value
                            // servo2Y.write(Min2Y); // Turn Servo 2 to Min Y value
                            // servo3Y.write(Min3Y); // Turn Servo 3 to Min Y value
                            //
                            // delay (1000);
                            //
                            // servo1.write(Max1X); // Turn Servo 1 to Max X value
                            // servo1.write(Max2X); // Turn Servo 2 to Max X value
                            // servo1.write(Max3X); // Turn Servo 3 to Max X value
                            //
                            // servo1Y.write(Max1Y); // Turn Servo 1 to Max Y value
                            // servo2Y.write(Max2Y); // Turn Servo 2 to Max Y value
                            // servo3Y.write(Max3Y); // Turn Servo 3 to Max Y value
                            //
                            // delay (1000);
                            }

                            Que j’aimerais bien mettre dans l’autre sketch (Teeces)

                            Code:

                            // =======================================================================================
                            // ============================ Universal Dome Lighting Sketch ===========================
                            // =======================================================================================
                            // Version : 2012-11-04 (added more PSI options)
                            //
                            // A sketch to run on an Arduino inside the dome. This runs Teeces lighting.
                            //
                            // Thrown together by Paul Murphy (JoyMonkey) from various sources including…
                            // John V, Michael Erwin, Michael Smith, Roger Moolay, Chris Reiff and Brad Oakley
                            //
                            // Required : http://arduino.cc/playground/uploads/Main/LedControl.zip
                            // (that’s an Arduino Library – it needs to be downloaded and extracted into your
                            // Libraries folder for this sketch to work)
                            //
                            // Logic Display and PSI Boards should be wired up in two chains (to prevent problems that
                            // some builders ran into when using a single chain setup for an extended period of time).
                            // In early 2012 a revised RLD board was released with two outputs to make wiring up in a
                            // two chain setup a little easier.
                            // V3.1 OUT2 uses Arduino Pro Micro or Pro Mini pins 9,8,7 for the FLDs and front PSI.
                            // If you’re using the older V3 RLD and don’t have the OUT2 pins, don’t panic! You can
                            // still wire up a front chain by connecting directly to the Arduino pins.
                            //
                            // If using a V3 RLD…
                            // RLD OUT -> Rear PSI
                            // Arduino Pins 9,8,7 -> FLD IN D,C,L -> FLD -> Front PSI
                            // (you will also need to supply +5V and GND to the front chain; it can go to any pins
                            // labeled +5V and GND on any of the FLD or front PSI boards)
                            //
                            // If using a V3.1 RLD connections are a little simpler…
                            // RLD OUT1 -> Rear PSI
                            // RLD OUT2 -> FLD -> FLD -> Front PSI
                            //
                            // This sketch will work with an Arduino Pro Micro or Pro Mini mounted to the RLD.
                            // The Pro Micro uses slightly different pin numbers and has additional small LEDs on it
                            // that we can blink back and forth to confirm it’s working (I call this microPSI).
                            // Because of these differences this sketch needs to be edited to suit a Pro Micro or a
                            // Pro Mini. If using a Pro Mini, simply delete the first line of code below…

                            //#define PROMICRO //delete or comment-out this line if you’re not using an Arduino Pro MICRO

                            char text[] = “BOOTING999 R28J4 READY”; //PUT YOUR STARTUP TEXT HERE.

                            // set brightness levels here (a value of 0-15)…
                            int RLDbright=5; //rear Logic
                            int RPSIbright=12; //rear PSI
                            int FLDbright=5; //front Logics
                            int FPSIbright=12; //front PSI

                            //delay time of logic display blinkyness (lower = blink faster)
                            int LogicBlinkTime=175;

                            //set the type of our front and rear PSI’s
                            #define PSItype 5
                            // 1 = Teeces original (6 LEDs of each color, arranged side by side)
                            // 2 = Teeces original checkerboard (6 LEDs of each color arranged in a checkerboard pattern)
                            // 3 = Teeces V3.2 PSI by John V (13 LEDs of each color, arranged side by side)
                            // 4 = Teeces V3.2 PSI checkerboard by John V (13 LEDs of each color, in a checkerboard pattern)
                            // 5 = Teeces V2 FLD converted to PSI with RafkeP’s original pattern

                            //set timing of the PSI’s here (in milliseconds)…
                            int psiRed=2500; //how long front PSI stays red
                            int psiBlue=1700; //how long front PSI stays blue
                            int psiYellow=1700; //how long rear PSI stays yellow
                            int psiGreen=2500; //how long rear PSI stays green
                            int rbSlide=300; // mts – time to transition between red and blue in slide mode
                            int ygSlide=300; // mts – time to transition between yellow and green in slide mode

                            //pulse the PSI Brightness (0=off, 1=Front, 2=Rear, 3=Both)
                            #define PSIPULSER 3

                            //#define TESTLOGICS //turns on all logic LEDs at once, useful for troubleshooting

                            //#define FLDx4 //for an R7 dome with 4 FLDs (if you have 4 FLDs then delete the first // )

                            // Most builders shouldn’t have to edit anything below here. Enjoy!
                            //
                            // =======================================================================================
                            // =======================================================================================

                            //for scrolling text on logics…
                            int pixelPos=27;
                            int scrollCount=0;
                            //virtual coords are 5×45; device coords are 3 panels 6×8 each
                            unsigned long v_grid[5]; //this will give 5×40 bits

                            #include
                            #undef round

                            #if defined(PROMICRO)
                            #define DVAL 14
                            #define CVAL 16
                            #else
                            #define DVAL 12
                            #define CVAL 11
                            #endif

                            #if defined(FLDx4)
                            #define FDEV 5 //5 devices for front chain
                            #define FPSIDEV 4 //front PSI is device #4 in the chain
                            #else
                            #define FDEV 3 //3 devices for front chain
                            #define FPSIDEV 2 //front PSI is device #2 in the chain
                            #endif

                            #define RPSIDEV 3 //rear PSI is device #3 in the chain

                            //START UP LEDCONTROL…
                            LedControl lcRear=LedControl(DVAL,CVAL,10,4); //rear chain (Pro Mini/Pro Micro pins)
                            LedControl lcFront=LedControl(9,8,7,FDEV); //front chain

                            // =======================================================================================
                            #if (PSItype==5) // slide animation code for RafkeP original pattern PSI boards (code by RafkeP)
                            //#define HPROW 5
                            class PSI {
                            int stage; //0 thru 9
                            int inc;
                            int stageDelay[10];
                            int cols[10][6];
                            int randNumber; //a random number to decide the fate of the last stage

                            unsigned long timeLast;
                            int device;

                            public:

                            PSI(int _delay1, int _delay2, int _delay3, int _device)
                            {
                            device=_device;

                            stage=0;
                            timeLast=0;
                            inc=1;

                            cols[0][0] = B01010101;
                            cols[0][1] = B10101010;
                            cols[0][2] = B01010101;
                            cols[0][3] = B10101010;
                            cols[0][4] = B01010101;
                            cols[0][5] = B01010000;

                            cols[1][0] = B11010101;
                            cols[1][1] = B00101010;
                            cols[1][2] = B11010101;
                            cols[1][3] = B00101010;
                            cols[1][4] = B11010101;
                            cols[1][5] = B01010000;

                            cols[2][0] = B10010101;
                            cols[2][1] = B01101010;
                            cols[2][2] = B10010101;
                            cols[2][3] = B01101010;
                            cols[2][4] = B10010101;
                            cols[2][5] = B01010000;

                            cols[3][0] = B10110101;
                            cols[3][1] = B01001010;
                            cols[3][2] = B10110101;
                            cols[3][3] = B01001010;
                            cols[3][4] = B10110101;
                            cols[3][5] = B01010000;

                            cols[4][0] = B10100101;
                            cols[4][1] = B01011010;
                            cols[4][2] = B10100101;
                            cols[4][3] = B01011010;
                            cols[4][4] = B10100101;
                            cols[4][5] = B01010000;

                            cols[5][0] = B10101101;
                            cols[5][1] = B01010010;
                            cols[5][2] = B10101101;
                            cols[5][3] = B01010010;
                            cols[5][4] = B10101101;
                            cols[5][5] = B01010000;

                            cols[6][0] = B10101001;
                            cols[6][1] = B01010110;
                            cols[6][2] = B10101001;
                            cols[6][3] = B01010110;
                            cols[6][4] = B10101001;
                            cols[6][5] = B01010000;

                            cols[7][0] = B10101011;
                            cols[7][1] = B01010100;
                            cols[7][2] = B10101011;
                            cols[7][3] = B01010100;
                            cols[7][4] = B10101011;
                            cols[7][5] = B01010000;

                            cols[8][0] = B10101010;
                            cols[8][1] = B01010101;
                            cols[8][2] = B10101010;
                            cols[8][3] = B01010101;
                            cols[8][4] = B10101010;
                            cols[8][5] = B01010000;

                            cols[9][0] = B10101010;
                            cols[9][1] = B01010101;
                            cols[9][2] = B10101010;
                            cols[9][3] = B01010101;
                            cols[9][4] = B10101010;
                            cols[9][5] = B10101000;

                            stageDelay[0] = _delay1 – _delay3;
                            stageDelay[1] = _delay3/8;
                            stageDelay[2] = _delay3/8;
                            stageDelay[3] = _delay3/8;
                            stageDelay[4] = _delay3/8;
                            stageDelay[5] = _delay3/8;
                            stageDelay[6] = _delay3/8;
                            stageDelay[7] = _delay3/8;
                            stageDelay[8] = _delay3/8;
                            stageDelay[9] = _delay2 – _delay3;
                            }

                            void Animate(unsigned long elapsed, LedControl control)
                            {
                            if ((elapsed – timeLast) < stageDelay[stage]) return; timeLast = elapsed; stage+=inc; if (stage>9 || stage<0 )
                            {
                            inc *= -1;
                            stage+=inc*2;
                            }
                            /*
                            if (stage==6) //randomly choose whether or not to go 'stuck'
                            {
                            randNumber = random(9);
                            if (randNumber<5) { //set the last stage to 'stuck'
                            cols[6][0] = B01010000;
                            cols[6][1] = B10101100;
                            cols[6][2] = B01010000;
                            cols[6][3] = B10101100;
                            cols[6][4] = B01010000;
                            }
                            else //reset the last stage to a solid color
                            {
                            cols[6][0] = B01010100;
                            cols[6][1] = B10101000;
                            cols[6][2] = B01010100;
                            cols[6][3] = B10101000;
                            cols[6][4] = B01010100;
                            }
                            }
                            if (stage==0) //randomly choose whether or not to go 'stuck'
                            {
                            randNumber = random(9);
                            if (randNumber<5) { //set the first stage to 'stuck'
                            cols[0][0] = B00101000; //R B R B R B
                            cols[0][1] = B11010100; //B R B R B R
                            cols[0][2] = B00101000; //R B R B R B
                            cols[0][3] = B11010100; //B R B R B R
                            cols[0][4] = B00101000; //R B R B R B
                            }
                            else //reset the first stage to a solid color
                            {
                            cols[0][0] = B10101000;
                            cols[0][1] = B01010100;
                            cols[0][2] = B10101000;
                            cols[0][3] = B01010100;
                            cols[0][4] = B10101000;
                            }
                            }
                            */
                            for (int row=0; row<6; row++)
                            control.setRow(device,row,cols[stage][row]);
                            }
                            };

                            #endif

                            // =======================================================================================
                            #if (PSItype==4) // slide animation code for Teeces V2 PSI boards (code by John V)
                            #define HPROW 5
                            class PSI {
                            int stage; //0 thru 6
                            int inc;
                            int stageDelay[7];
                            int cols[7][5];
                            int randNumber; //a random number to decide the fate of the last stage

                            unsigned long timeLast;
                            int device;

                            public:

                            PSI(int _delay1, int _delay2, int _delay3, int _device)
                            {
                            device=_device;

                            stage=0;
                            timeLast=0;
                            inc=1;

                            cols[0][0] = B10101000;
                            cols[0][1] = B01010100;
                            cols[0][2] = B10101000;
                            cols[0][3] = B01010100;
                            cols[0][4] = B10101000;

                            cols[1][0] = B00101000; //R B R B R B
                            cols[1][1] = B11010100; //B R B R B R
                            cols[1][2] = B00101000; //R B R B R B
                            cols[1][3] = B11010100; //B R B R B R
                            cols[1][4] = B00101000; //R B R B R B

                            cols[2][0] = B01101000;
                            cols[2][1] = B10010100;
                            cols[2][2] = B01101000;
                            cols[2][3] = B10010100;
                            cols[2][4] = B01101000;

                            cols[3][0] = B01001000;
                            cols[3][1] = B10110100;
                            cols[3][2] = B01001000;
                            cols[3][3] = B10110100;
                            cols[3][4] = B01001000;

                            cols[4][0] = B01011000;
                            cols[4][1] = B10100100;
                            cols[4][2] = B01011000;
                            cols[4][3] = B10100100;
                            cols[4][4] = B01011000;

                            cols[5][0] = B01010000;
                            cols[5][1] = B10101100;
                            cols[5][2] = B01010000;
                            cols[5][3] = B10101100;
                            cols[5][4] = B01010000;

                            cols[6][0] = B01010100;
                            cols[6][1] = B10101000;
                            cols[6][2] = B01010100;
                            cols[6][3] = B10101000;
                            cols[6][4] = B01010100;

                            stageDelay[0] = _delay1 - _delay3;
                            stageDelay[1] = _delay3/5;
                            stageDelay[2] = _delay3/5;
                            stageDelay[3] = _delay3/5;
                            stageDelay[4] = _delay3/5;
                            stageDelay[5] = _delay3/5;
                            stageDelay[6] = _delay2 - _delay3;
                            }

                            void Animate(unsigned long elapsed, LedControl control)
                            {
                            if ((elapsed - timeLast) < stageDelay[stage]) return; timeLast = elapsed; stage+=inc; if (stage>6 || stage<0 )
                            {
                            inc *= -1;
                            stage+=inc*2;
                            }

                            if (stage==6) //randomly choose whether or not to go 'stuck'
                            {
                            randNumber = random(9);
                            if (randNumber<5) { //set the last stage to 'stuck'
                            cols[6][0] = B01010000;
                            cols[6][1] = B10101100;
                            cols[6][2] = B01010000;
                            cols[6][3] = B10101100;
                            cols[6][4] = B01010000;
                            }
                            else //reset the last stage to a solid color
                            {
                            cols[6][0] = B01010100;
                            cols[6][1] = B10101000;
                            cols[6][2] = B01010100;
                            cols[6][3] = B10101000;
                            cols[6][4] = B01010100;
                            }
                            }
                            if (stage==0) //randomly choose whether or not to go 'stuck'
                            {
                            randNumber = random(9);
                            if (randNumber<5) { //set the first stage to 'stuck'
                            cols[0][0] = B00101000; //R B R B R B
                            cols[0][1] = B11010100; //B R B R B R
                            cols[0][2] = B00101000; //R B R B R B
                            cols[0][3] = B11010100; //B R B R B R
                            cols[0][4] = B00101000; //R B R B R B
                            }
                            else //reset the first stage to a solid color
                            {
                            cols[0][0] = B10101000;
                            cols[0][1] = B01010100;
                            cols[0][2] = B10101000;
                            cols[0][3] = B01010100;
                            cols[0][4] = B10101000;
                            }
                            }

                            for (int row=0; row<5; row++)
                            control.setRow(device,row,cols[stage][row]);
                            }
                            };

                            #endif

                            // =======================================================================================
                            #if (PSItype==3) // slide animation code for Teeces V2 PSI boards (code by John V)
                            #define HPROW 5
                            class PSI {
                            int stage; //0 thru 6
                            int inc;
                            int stageDelay[7];
                            int cols[7];

                            unsigned long timeLast;
                            int device;

                            public:

                            PSI(int _delay1, int _delay2, int _delay3, int _device)
                            {
                            device=_device;

                            stage=0;
                            timeLast=0;
                            inc=1;

                            cols[0] = B11100000;
                            cols[1] = B11110000;
                            cols[2] = B01110000;
                            cols[3] = B01111000;
                            cols[4] = B00111000;
                            cols[5] = B00111100;
                            cols[6] = B00011100;

                            stageDelay[0] = _delay1 - _delay3;
                            stageDelay[1] = _delay3/5;
                            stageDelay[2] = _delay3/5;
                            stageDelay[3] = _delay3/5;
                            stageDelay[4] = _delay3/5;
                            stageDelay[5] = _delay3/5;
                            stageDelay[6] = _delay2 - _delay3;
                            }
                            void Animate(unsigned long elapsed, LedControl control)
                            {
                            if ((elapsed - timeLast) < stageDelay[stage]) return; timeLast = elapsed; stage+=inc; if (stage>6 || stage<0 )
                            {
                            inc *= -1;
                            stage+=inc*2;
                            }

                            for (int row=0; row<5; row++)
                            control.setRow(device,row,cols[stage]);
                            }
                            };
                            #endif
                            // =======================================================================================
                            //michael smith's checkerboard PSI method for Teeces original PSI boards
                            // Michael's original sketch is here : http://pastebin.com/hXeZb7Gd
                            #if (PSItype==2)
                            #define HPROW 4
                            static const int patternAtStage[] = { B01010000, B11010000, B10010000, B10110000, B10100000, B00100000, B01100000, B01000000, B01010000 };
                            class PSI
                            {
                            bool state;
                            int stage;
                            unsigned long timeLast;
                            int delay1, delay2, delay3;
                            int device;
                            int delayAtStage[9];
                            int slideDirection; // is either 1 or -1
                            int maxStage; // for PSIslide it's either 5 or 9 stages, for traditional PSI it's just back and forth between 2
                            public:
                            PSI(int _delay1, int _delay2, int _delay3, int _device)
                            {
                            delayAtStage[0] = _delay1;
                            delayAtStage[1] = _delay3/3; // delay3 is total transition time - divide it by the 3 stages of transition
                            delayAtStage[2] = delayAtStage[1];
                            delayAtStage[3] = delayAtStage[1];
                            delayAtStage[4] = _delay2;
                            delayAtStage[5] = delayAtStage[1];
                            delayAtStage[6] = delayAtStage[1];
                            delayAtStage[7] = delayAtStage[1];
                            delayAtStage[8] = _delay1; // repeated because it's not a loop it cycles back and forth across the pattern.
                            stage=0;
                            slideDirection=1;
                            maxStage=8; // change to 5 would skip the LtoR from blue to red.
                            timeLast=0;
                            device=_device;
                            // legacy for traditional PSI animation
                            delay1=_delay1;
                            delay2=_delay2;
                            delay3=_delay3;
                            state=false;
                            }
                            void Animate(unsigned long timeNow, LedControl control)
                            {
                            if ((timeNow - timeLast) < delayAtStage[stage]) return; //Serial.begin(9600); //Serial.println(stage); //Serial.println(patternAtStage[stage]); timeLast = timeNow; stage+=slideDirection; //move to the next stage, which could be up or down in the array if (stage >= maxStage)
                            {
                            // limit the stage to the maxStage and reverse the direction of the slide
                            stage=maxStage;
                            slideDirection = -1;
                            }
                            else if (stage <= 0) { stage=0; slideDirection = 1; } // set the patterns for this stage control.setRow(device,0,patternAtStage[stage]); control.setRow(device,1,~patternAtStage[stage]); control.setRow(device,2,patternAtStage[stage]); control.setRow(device,3,~patternAtStage[stage]); } }; #endif // ======================================================================================= // slide animation code for Teeces original PSI boards #if (PSItype==1) #define HPROW 4 class PSI { int stage; //0 thru 4 int inc; int stageDelay[5]; int cols[5]; unsigned long timeLast; int device; public: PSI(int _delay1, int _delay2, int _device) { device=_device; stage=0; timeLast=0; inc=1; cols[0] = B11000000; cols[1] = B11100000; cols[2] = B01100000; cols[3] = B01110000; cols[4] = B00110000; stageDelay[0] = _delay1 - 300; stageDelay[1] = 100; stageDelay[2] = 100; stageDelay[3] = 100; stageDelay[4] = _delay2 - 300; } void Animate(unsigned long elapsed, LedControl control) { if ((elapsed - timeLast) < stageDelay[stage]) return; timeLast = elapsed; stage+=inc; if (stage>4 || stage<0 ) {
                            inc *= -1;
                            stage+=inc*2;
                            }
                            for (int row=0; row<4; row++) control.setRow(device,row,cols[stage]);
                            }
                            };
                            #endif
                            // =======================================================================================
                            #if (PSItype==1)
                            PSI psiFront=PSI(psiRed, psiBlue, FPSIDEV); // device is FPSIDEV (#2 or #4 for an R7 dome)
                            PSI psiRear =PSI(psiYellow, psiGreen, RPSIDEV); // device is #3
                            //#endif
                            //#if (PSItype==2) || (PSItype==3)
                            #else
                            PSI psiFront=PSI(psiRed, psiBlue, rbSlide, FPSIDEV); //2000 ms on red, 1000 ms on blue.
                            PSI psiRear =PSI(psiYellow, psiGreen, ygSlide, RPSIDEV); //1000 ms on yellow, 2000 ms on green.
                            #endif
                            // =======================================================================================
                            void setup() {
                            Serial.begin(9600); //used for debugging
                            for(int dev=0;dev0
                            PSIpulse(timeNew);
                            #endif
                            }
                            // =======================================================================================
                            // this is the code to blink all the logic LEDs randomly…
                            void animateLogic(unsigned long elapsed) {
                            static unsigned long timeLast=0;
                            if ((elapsed – timeLast) < LogicBlinkTime) return; timeLast = elapsed; #if defined(TESTLOGICS) //turn on all logic LEDs to make sure they're all working for (int dev=0; dev<3; dev++) for (int row=0; row<6; row++) lcRear.setRow(dev,row,255); for (int dev=0; dev0
                            int pulseState = LOW; //initial state of our PSI (high intensity, going down)
                            int pulseVal = 15; //initial value of our PSI (full intensity)
                            void PSIpulse(unsigned long elapsed) {
                            static unsigned long timeLast=0;
                            if ((elapsed – timeLast) < 100) return; //proceed if 100 milliseconds have passed timeLast = elapsed; if (pulseState == HIGH) { //increase intensity pulseVal++; //increase value by 1 if (pulseVal == 16) { //if we've gone beyond full intensity, start going down again pulseVal = 15; pulseState = LOW; } } else { //decrease intensity pulseVal--; //increase value by 1 if (pulseVal == 0) { //if we've gone beyond full intensity, start going down again pulseVal = 1; pulseState = HIGH; } } #if PSIPULSER==1 || PSIPULSER==3 lcFront.setIntensity(2,pulseVal); //set the front intensity #endif #if PSIPULSER==2 || PSIPULSER==3 lcRear.setIntensity(3,pulseVal); //set the rear intensity #endif } #endif //////////////////////////////////// // ======================================================================================= // AUREBESH CHARACTERS TAKEN FROM MOOLAY'S SKETCH // http://astromech.net/forums/showthread.php?p=99487 void showGrid() { //copy from virt coords to device coords unsigned char col8=0; unsigned char col17=0; unsigned char col26=0; for (int row=0; row<5; row++) { lcRear.setRow(0,row, rev( v_grid[row] & 255L ) ); //device 0 lcRear.setRow(1,row, rev( (v_grid[row] & 255L<<9) >> 9 ) ); //device 1
                            lcRear.setRow(2,row, rev( (v_grid[row] & 255L<<18) >> 18 ) ); //device 2
                            lcFront.setRow(0,row, rev( v_grid[row] & 255L ) ); //device 0
                            lcFront.setRow(1,row, rev( (v_grid[row] & 255L<<9) >> 9 ) ); //device 1
                            if ( (v_grid[row] & 1L<<8) == 1L<<8) col8 += 128>>row;
                            if ( (v_grid[row] & 1L<<17) == 1L<<17) col17 += 128>>row;
                            if ( (v_grid[row] & 1L<<26) == 1L<<26) col26 += 128>>row;
                            }
                            lcRear.setRow(0, 5, col8);
                            lcRear.setRow(1, 5, col17);
                            lcRear.setRow(2, 5, col26);
                            lcFront.setRow(0, 5, col8);
                            lcFront.setRow(1, 5, col17);
                            }
                            unsigned char rev(unsigned char b) {
                            //reverse bits of a byte
                            return (b * 0x0202020202ULL & 0x010884422010ULL) % 1023;
                            }
                            void initGrid() {
                            for (int row=0; row<6; row++) v_grid[row]=0L;
                            }
                            int c9[] = {
                            B00000000,
                            B00000000,
                            B00000000,
                            B00000000,
                            B00000100 };
                            int c8[] = {
                            B00000000,
                            B00000000,
                            B00001111,
                            B00000000,
                            B00000000 };
                            int c4[] = {
                            B00001001,
                            B00001001,
                            B00001111,
                            B00001000,
                            B00001000 };
                            int c2[] = {
                            B00001111,
                            B00001000,
                            B00001111,
                            B00000001,
                            B00001111 };
                            int cA[] = { B00000110,
                            B00001001,
                            B00001111,
                            B00001001,
                            B00001001 };

                            int cB[] = { B00000111,
                            B00001001,
                            B00000111,
                            B00001001,
                            B00000111 };

                            int cC[] = { B00000110,
                            B00001001,
                            B00000001,
                            B00001001,
                            B00000110 };

                            int cD[] = { B0000111,
                            B0001001,
                            B0001001,
                            B0001001,
                            B0000111 };

                            int cE[] = { B00001111,
                            B00000001,
                            B00000111,
                            B00000001,
                            B00001111 };

                            int cF[] = { B00001111,
                            B00000001,
                            B00000111,
                            B00000001,
                            B00000001 };

                            int cG[] = { B00001110,
                            B00000001,
                            B00001101,
                            B00001001,
                            B00000110 };

                            int cH[] = { B00001001,
                            B00001001,
                            B00001111,
                            B00001001,
                            B00001001 };

                            int cI[] = { B00000111,
                            B00000010,
                            B00000010,
                            B00000010,
                            B00000111 };

                            int cJ[] = { B00001000,
                            B00001000,
                            B00001000,
                            B00001001,
                            B00000110 };

                            int cK[] = { B00001001,
                            B00000101,
                            B00000011,
                            B00000101,
                            B00001001 };

                            int cL[] = { B00000001,
                            B00000001,
                            B00000001,
                            B00000001,
                            B00001111 };

                            int cM[] = { B00010001,
                            B00011011,
                            B00010101,
                            B00010001,
                            B00010001 };

                            int cN[] = { B00001001,
                            B00001011,
                            B00001101,
                            B00001001,
                            B00001001 };

                            int cO[] = { B00000110,
                            B00001001,
                            B00001001,
                            B00001001,
                            B00000110 };

                            int cP[] = { B00000111,
                            B00001001,
                            B00000111,
                            B00000001,
                            B00000001 };

                            int cQ[] = { B00000110,
                            B00001001,
                            B00001101,
                            B00001001,
                            B00010110 };

                            int cR[] = { B00000111,
                            B00001001,
                            B00000111,
                            B00000101,
                            B00001001 };

                            int cS[] = { B00001110,
                            B00000001,
                            B00000110,
                            B00001000,
                            B00000111 };

                            int cT[] = { B00011111,
                            B00000100,
                            B00000100,
                            B00000100,
                            B00000100 };

                            int cU[] = { B00001001,
                            B00001001,
                            B00001001,
                            B00001001,
                            B00000110 };

                            int cV[] = { B00010001,
                            B00010001,
                            B00010001,
                            B00001010,
                            B00000100 };

                            int cW[] = { B00010001,
                            B00010001,
                            B00010001,
                            B00010101,
                            B00011011 };

                            int cX[] = { B00010001,
                            B00001010,
                            B00000100,
                            B00001010,
                            B00010001 };

                            int cY[] = { B00010001,
                            B00010001,
                            B00001010,
                            B00000100,
                            B00000100 };

                            int cZ[] = { B00011111,
                            B00001000,
                            B00000100,
                            B00000010,
                            B00011111 };
                            int cZZ[] = {
                            B00000000,
                            B00000000,
                            B00000000,
                            B00000000,
                            B00000000 };
                            int co[] = {
                            B01010101,
                            B01010101,
                            B01010101,
                            B01010101,
                            B01010101 };
                            void drawLetter(char let, int shift) {
                            int *pLetter;
                            switch (let) {
                            case '9': pLetter=c9; break;
                            case '8': pLetter=c8; break;
                            case '4': pLetter=c4; break;
                            case '2': pLetter=c2; break;
                            case 'A': pLetter=cA; break;
                            case 'B': pLetter=cB; break;
                            case 'C': pLetter=cC; break;
                            case 'D': pLetter=cD; break;
                            case 'E': pLetter=cE; break;
                            case 'F': pLetter=cF; break;
                            case 'G': pLetter=cG; break;
                            case 'H': pLetter=cH; break;
                            case 'I': pLetter=cI; break;
                            case 'J': pLetter=cJ; break;
                            case 'K': pLetter=cK; break;
                            case 'L': pLetter=cL; break;
                            case 'M': pLetter=cM; break;
                            case 'N': pLetter=cN; break;
                            case 'O': pLetter=cO; break;
                            case 'P': pLetter=cP; break;
                            case 'Q': pLetter=cQ; break;
                            case 'R': pLetter=cR; break;
                            case 'S': pLetter=cS; break;
                            case 'T': pLetter=cT; break;
                            case 'U': pLetter=cU; break;
                            case 'V': pLetter=cV; break;
                            case 'W': pLetter=cW; break;
                            case 'X': pLetter=cX; break;
                            case 'Y': pLetter=cY; break;
                            case 'Z': pLetter=cZ; break;
                            case '_': pLetter=cZZ; break;
                            default:return;
                            }
                            //loop thru rows of the letter
                            for (int i=0; i<5; i++) {
                            if (shift>0) //positive shift means letter is slid to the right on the display
                            v_grid[i] += (long)pLetter[i] << shift; else //negative shift means letter is slid to the left so that only part of it is visible v_grid[i] += (long)pLetter[i] >> -shift;
                            }
                            }
                            void scrollingText() {
                            for (int i=0; i

                            A chaque fois que je teste j’ai des messages d’erreurs…

                            Merci d’avance :)

                            #104470
                            Anonyme

                              Bon déjà je viens de m’apercevoir que certaines pins étaient utilisées dans les deux sketches, pas bon. :) Comme pour le moment je ne vais que motoriser le HP de devant je n’ai donc besoin que deux servos et donc 2 pins, et je ne veux pas toucher aux pins du Teeces. Je replonge dedans :)

                              #104471
                              Anonyme

                                Bon j’ai essayé de retirer tout ce qui ne m’était pas nécessaire dans le sketch HP. :)

                                Code:

                                /*
                                * SARLACC For Holo Projectors v 0.3a
                                *
                                * – Simple
                                * – Arduino
                                * – Random Holoprojector
                                * – Location for
                                * – AstroMech Builders
                                * – Club
                                * – Control
                                *
                                * Micke Askernäs, 2012
                                *
                                */

                                #include

                                /*
                                * User defined constants
                                * change these for finetuning your servos
                                * *NOTE* These values are set for my servos.
                                * In order to get your system running smooth, you need to
                                * set your own values. See test code at the bottom of code.
                                */

                                const int Min1X = 45; // Min value for X1
                                const int Max1X = 150; // Max value for X1
                                const int Min1Y = 0; // Min value for Y1
                                const int Max1Y = 130; // Max value for Y1

                                const int MinTime = 1000; // Minimum time to wait before another servo movement.
                                const int MaxTime = 6000; // Maximum time to wait before another servo movement.

                                /*
                                * Arduino Pin Configuration
                                * Change these if needed
                                */

                                const int servo1Xpin = 6; // PIN on Arduino used for Servo1X
                                const int servo1Ypin = 5; // PIN on Arduino used for Servo1Y

                                /*
                                * End Arduino Pin Configuration
                                */

                                /*
                                * End constants
                                */

                                /* No more changes should be needed below this line. */

                                Servo servo1X; // Define X-Servo 1 (Front)
                                Servo servo1Y; // Define Y-Servo 1 (Front)

                                unsigned long currentTime;
                                unsigned long loopTime;

                                void setup()
                                {
                                servo1X.attach(servo1Xpin); // Attaching servo to defined pin.
                                servo1Y.attach(servo1Ypin); // Attaching servo to defined pin.

                                randomSeed(analogRead(0)); // Feed unhooked analog input as seed for randomizer. Can be set to static number.
                                // randomSeed(3141592653); // Static number random Seed (for explanantion only)

                                currentTime = millis();
                                loopTime = currentTime;
                                }

                                void loop()
                                {
                                currentTime = millis();

                                /* Loop 1 for Servo1 */
                                if (currentTime >= (loopTime + random(MinTime,MaxTime))) {
                                servo1X.write(random(Min1X,Max1X)); // Turn X-Servo to random X value (0-180)
                                servo1Y.write(random(Min1Y,Max1Y)); // Turn Y-Servo to random X value (0-180)
                                loopTime = currentTime;
                                }

                                /*
                                * Loop for testing max and min values – Comment this out or remove for working program
                                * Recommended to take one servo at the time and test out the min/max values on X first, then Y
                                * and then move on to next servo.
                                */

                                // servo1X.write(Min1X); // Turn Servo 1 to Min X value
                                // servo2X.write(Min2X); // Turn Servo 2 to Min X value
                                // servo3X.write(Min3X); // Turn Servo 3 to Min X value
                                //
                                // servo1Y.write(Min1Y); // Turn Servo 1 to Min Y value
                                // servo2Y.write(Min2Y); // Turn Servo 2 to Min Y value
                                // servo3Y.write(Min3Y); // Turn Servo 3 to Min Y value
                                //
                                // delay (1000);
                                //
                                // servo1.write(Max1X); // Turn Servo 1 to Max X value
                                // servo1.write(Max2X); // Turn Servo 2 to Max X value
                                // servo1.write(Max3X); // Turn Servo 3 to Max X value
                                //
                                // servo1Y.write(Max1Y); // Turn Servo 1 to Max Y value
                                // servo2Y.write(Max2Y); // Turn Servo 2 to Max Y value
                                // servo3Y.write(Max3Y); // Turn Servo 3 to Max Y value
                                //
                                // delay (1000);
                                }

                                J’espère n’avoir pas fait de bêtise. :)

                              14 sujets de 1 à 14 (sur un total de 14)
                              • Vous devez être connecté pour répondre à ce sujet.