Jump to content

BBruno

Member
  • Posts

    4
  • Joined

  • Last visited

Posts posted by BBruno

  1. @Del

     

    a idea

    
    const int BPTrigg = 2;
    const int BPReload = 3;
    int EtatTrigg, LastTrigg;
    int Choice, Reload, Select;
    unsigned long Tempo;
    int Fire;
    
    void setup() {
      pinMode(BPTrigg, INPUT);
      pinMode(BPReload, INPUT);
    
    } //end setup
    
    void loop() {
    
      // trigger
      if (digitalRead(BPTrigg)==HIGH) {EtatTrigg=1;} else {EtatTrigg=0;}
      if (EtatTrigg !=LastTrigg) {
        if (EtatTrigg==1) {
          Fire=1; } // sound+light..and Fire=0;
          LastTrigg = EtatTrigg;  }   
    
      // button 2 for reload and button 2 held down for a couple seconds for weapon select
      if (digitalRead(BPReload)==HIGH) {if (Tempo==0) {Tempo=millis(); Choice=1; } }
        else { if (Choice==1 &&  millis()<Tempo+2000) {Reload=1; Choice=0;}
               if (Choice==1 &&  millis()>Tempo+2000) {Select=1; Choice=0;} }
    
    // Reload = sound+light..and Reload=0;      
    // Select = sound..and Select=0;
    
    } //end loop
    
  2. HI,
    very nice work
    I'll throw myself too


    @JohnDoe2000  an example=

    10 SEGMENT LED BAR GRAPH DISPLAY  with 4 wires: +/- (3,3v) and clk/dio.  No resistors  :)

    http://www.conrad.fr/ce/fr/product/1267854/platine-dextension-pour-Linker-Kit-LK-LEDM-Barre?queryFromSuggest=true

     

    https://www.youtube.com/watch?v=PJMMoY5VFF0

     

     

    // demo of Grove - Led Bar
    /*
     * sort LedBarre I2C de 0 a 10
     * maintenant avec un BP on diminue le compte
     */

    #include <LED_Bar.h>

    LED_Bar bar(8, 7);                  // config Io here, (clk, dio)
    int i; int T; int Cmpt=10;
    int EtatBP; int LastBP; const int BPPin = 11;


    void setup()
    {
       Serial.begin(9600);

      pinMode(BPPin, INPUT);

    }//fin setup

    void loop(){

      if (digitalRead(BPPin)==HIGH) {EtatBP=1;} else {EtatBP=0;}
      if (EtatBP !=LastBP) {
        if (EtatBP==1) {
          Cmpt--;}
          LastBP = EtatBP;  }

         for(int R=10; R >=0; R--) {
           if (Cmpt > R) {bar.setSingleLed(R, 1);}
             else {bar.setSingleLed(R, 0);}  }   


      Serial.print("  Cmpt  "); Serial.println(Cmpt);


     
    }//fin loop

    • Like 2
×
×
  • Create New...