Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_NeoPixel.h>
- #define PIN 5
- #define NombreLeds 32
- int SensDuVent;
- int PositionLedSensDuVent;
- int PositionLedSensDuVentOpp;
- int Val;
- bool CAS1 =false;
- bool CAS2 =false;
- bool CAS3 =false;
- bool CAS4 =false;
- bool CAS5 =false;
- Adafruit_NeoPixel ring (NombreLeds, PIN, NEO_BGR + NEO_KHZ800);
- void setup()
- {
- ring.begin();
- ring.clear();
- ring.setBrightness(0);
- ring.show();
- Serial.begin(9600);
- }
- void loop()
- {
- Val = analogRead (A3);
- delay (10);
- /*if (Val >1023)
- {
- Val = 1023;
- }*/
- SensDuVent = (int) map(Val, 0, 1024, 0, 360);
- PositionLedSensDuVent = (int)(NombreLeds*SensDuVent/360);
- if (PositionLedSensDuVent == 32 || PositionLedSensDuVent == 0)
- //if ( (0 < PositionLedSensDuVent +1 && PositionLedSensDuVent > 31) || (0 <= PositionLedSensDuVent <= 0))
- {
- PositionLedSensDuVent = 0;
- PositionLedSensDuVentOpp = 16;
- CAS1 =true;
- CAS2 =false;
- CAS3 =false;
- CAS4 =false;
- }
- //if ( 0 < PositionLedSensDuVent < 16)
- if ( 0 < PositionLedSensDuVent && PositionLedSensDuVent < 16)
- {
- PositionLedSensDuVentOpp = PositionLedSensDuVent + 16;
- CAS1 =false;
- CAS2 =true;
- CAS3 =false;
- CAS4 =false;
- }
- //if (PositionLedSensDuVent == 16)
- if (15 < PositionLedSensDuVent && PositionLedSensDuVent < 17)
- {
- PositionLedSensDuVentOpp = 0;
- CAS1 =false;
- CAS2 =false;
- CAS3 =true;
- CAS4 =false;
- }
- if (PositionLedSensDuVent > 16)
- {
- PositionLedSensDuVentOpp = PositionLedSensDuVent - 16;
- if ( 15 < PositionLedSensDuVent && PositionLedSensDuVent < 17)
- {
- PositionLedSensDuVentOpp = 32;
- }
- if( 16 < PositionLedSensDuVent && PositionLedSensDuVent <= 31)
- {
- PositionLedSensDuVentOpp = PositionLedSensDuVent -16;
- }
- CAS1 =false;
- CAS2 =false;
- CAS3 =false;
- CAS4 =true;
- }
- delay (5);
- Serial.print ("SensDuVent = ");
- Serial.println (SensDuVent);
- Serial.print (" ");
- Serial.print ("PositionLedSensDuVent = ");
- Serial.println (PositionLedSensDuVent);
- Serial.print (" ");
- Serial.print ("PositionLedSensDuVentOpp = ");
- Serial.println (PositionLedSensDuVentOpp);
- Serial.print (" ");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement