Advertisement
claudiusmarius

Cyril01

Dec 8th, 2022
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.29 KB | None | 0 0
  1. #include <Adafruit_NeoPixel.h>
  2.   #define PIN 5
  3.   #define NombreLeds 32
  4.  
  5.   int SensDuVent;
  6.   int PositionLedSensDuVent;
  7.   int PositionLedSensDuVentOpp;
  8.  
  9.   int Val;
  10.  
  11.   bool CAS1 =false;
  12.   bool CAS2 =false;
  13.   bool CAS3 =false;
  14.   bool CAS4 =false;
  15.  
  16.   bool CAS5 =false;
  17.  
  18.   Adafruit_NeoPixel ring (NombreLeds, PIN, NEO_BGR + NEO_KHZ800);
  19.  
  20.   void setup()
  21.   {
  22.   ring.begin();
  23.   ring.clear();
  24.   ring.setBrightness(0);
  25.   ring.show();
  26.  
  27.   Serial.begin(9600);
  28.   }
  29.  
  30.   void loop()
  31.   {
  32.   Val = analogRead (A3);
  33.   delay (10);
  34.   /*if (Val >1023)
  35.   {
  36.   Val = 1023;
  37.   }*/
  38.   SensDuVent = (int) map(Val, 0, 1024, 0, 360);
  39.   PositionLedSensDuVent = (int)(NombreLeds*SensDuVent/360);
  40.  
  41.   if (PositionLedSensDuVent == 32 || PositionLedSensDuVent == 0)
  42.  
  43.   //if ( (0 < PositionLedSensDuVent +1 && PositionLedSensDuVent > 31) || (0 <= PositionLedSensDuVent <= 0))
  44.    
  45.   {
  46.   PositionLedSensDuVent = 0;
  47.   PositionLedSensDuVentOpp = 16;
  48.   CAS1 =true;
  49.   CAS2 =false;
  50.   CAS3 =false;
  51.   CAS4 =false;
  52.  
  53.   }
  54.  
  55.   //if ( 0 < PositionLedSensDuVent < 16)
  56.  
  57.   if ( 0 < PositionLedSensDuVent && PositionLedSensDuVent < 16)
  58.  
  59.   {
  60.   PositionLedSensDuVentOpp = PositionLedSensDuVent + 16;
  61.   CAS1 =false;
  62.   CAS2 =true;
  63.   CAS3 =false;
  64.   CAS4 =false;
  65.  
  66.   }
  67.  
  68.   //if (PositionLedSensDuVent == 16)
  69.   if (15 < PositionLedSensDuVent && PositionLedSensDuVent < 17)
  70.  
  71.   {
  72.   PositionLedSensDuVentOpp = 0;
  73.   CAS1 =false;
  74.   CAS2 =false;
  75.   CAS3 =true;
  76.   CAS4 =false;
  77.  
  78.   }
  79.    
  80.   if (PositionLedSensDuVent > 16)
  81.   {
  82.   PositionLedSensDuVentOpp = PositionLedSensDuVent - 16;
  83.  
  84.   if (  15 < PositionLedSensDuVent && PositionLedSensDuVent < 17)
  85.   {
  86.   PositionLedSensDuVentOpp = 32;
  87.   }
  88.   if( 16 < PositionLedSensDuVent && PositionLedSensDuVent <= 31)
  89.   {
  90.   PositionLedSensDuVentOpp = PositionLedSensDuVent -16;  
  91.   }
  92.    
  93.   CAS1 =false;
  94.   CAS2 =false;
  95.   CAS3 =false;
  96.   CAS4 =true;
  97.  
  98.   }
  99.  
  100.   delay (5);
  101.   Serial.print ("SensDuVent               =   ");
  102.   Serial.println (SensDuVent);
  103.   Serial.print (" ");
  104.  
  105.   Serial.print ("PositionLedSensDuVent               =   ");
  106.   Serial.println (PositionLedSensDuVent);
  107.   Serial.print (" ");
  108.  
  109.   Serial.print ("PositionLedSensDuVentOpp               =   ");
  110.   Serial.println (PositionLedSensDuVentOpp);
  111.   Serial.print (" ");
  112.  
  113.  
  114.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement