Motor LEDs Behaviours

Hi, I had a look at the codeof update_motor_leds(void), and I think it might be usefull to code some logic in order to have visual signification from these motor LEDs.

I will try this, which test Motor arming ang GPS lock. I have a quad in X configuration:

 

static void update_motor_leds(void)
{

    static bool blink = false;
    static int blinkCycle = 4;
   
    // Motor not armed : Test GPS
    if(motor_armed == false){
      switch (g_gps->status()){
 
          case(2): // GPS lock : Blink front/back
          if (blink){
              digitalWrite(LE_LED, HIGH);
              digitalWrite(FR_LED, HIGH);
              digitalWrite(RI_LED, LOW);
              digitalWrite(RE_LED, LOW);
          }else{
              digitalWrite(LE_LED, LOW);
              digitalWrite(FR_LED, LOW);
              digitalWrite(RI_LED, HIGH);
              digitalWrite(RE_LED, HIGH);
          }
              break;
  
          default:  // GPS not lock : Blink sequence

              digitalWrite(LE_LED, ( (blinkCycle == 4 ) ? HIGH : LOW));
              digitalWrite(FR_LED, ( (blinkCycle == 3 ) ? HIGH : LOW));
              digitalWrite(RI_LED, ( (blinkCycle == 2 ) ? HIGH : LOW));
              digitalWrite(RE_LED, ( (blinkCycle == 1 ) ? HIGH : LOW));
              break;
      }   
  }else{ // Motor armed : Blink Simultaneously
          if(blinkCycle <2){
            digitalWrite(LE_LED, HIGH);
              digitalWrite(FR_LED, HIGH);
              digitalWrite(RI_LED, HIGH);
              digitalWrite(RE_LED, HIGH);
          } else{
            digitalWrite(LE_LED, LOW);
              digitalWrite(FR_LED, LOW);
              digitalWrite(RI_LED, LOW);
              digitalWrite(RE_LED, LOW);
        }
  }
       
    blink = !blink;
    //blincking cycle management
    blinkCycle--;
    if( blinkCycle<1) blinkCycle = 4;

    // the variable low_batt is here to let people know the voltage is low or the pack capacity is finished
    // I don't know what folks want here.
    // low_batt
}

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • 100KM

    Would be a nice addition !!!  

     

This reply was deleted.

Activity

Gremsy liked Gremsy's profile
Mar 12
DIY Robocars via Twitter
RT @chr1sa: Donkeycar 4.4 released with tons of new features, including path learning (useful with GPS outdoors), better Web and Lidar supp…
Nov 27, 2022
DIY Robocars via Twitter
RT @NXP: We are already biting our nails in anticipation of the #NXPCupEMEA challenge! 😉 Did you know there are great cash prizes to be won…
Nov 24, 2022
DIY Robocars via Twitter
RT @gclue_akira: レースまであと3日。今回のコースは激ムズかも。あと一歩 #jetracer https://t.co/GKcEjImQ3t
Nov 24, 2022
DIY Robocars via Twitter
UC Berkeley's DIY robocar program https://roar.berkeley.edu/
Nov 24, 2022
DIY Robocars via Twitter
RT @chr1sa: The next @DIYRobocars autonomous car race at @circuitlaunch will be on Sat, Dec 10. Thrills, spills and a Brazilian BBQ. Fun…
Nov 24, 2022
DIY Robocars via Twitter
RT @arthiak_tc: Donkey car platform ... Still training uses behavioral cloning #TCXpo #diyrobocar @OttawaAVGroup https://t.co/PHBYwlFlnE
Nov 20, 2022
DIY Robocars via Twitter
RT @emurmur77: Points for style. @donkeycar racing in @diyrobocars at @UCSDJacobs thanks @chr1sa for taking the video. https://t.co/Y2hMyj1…
Nov 20, 2022
DIY Robocars via Twitter
RT @SmallpixelCar: Going to @diyrobocars race at @UCSDJacobs https://t.co/Rrf9vDJ8TJ
Nov 8, 2022
DIY Robocars via Twitter
RT @SmallpixelCar: Race @diyrobocars at @UCSDJacobs thanks @chr1sa for taking the video. https://t.co/kK686Hb9Ej
Nov 8, 2022
DIY Robocars via Twitter
RT @PiWarsRobotics: Presenting: the Hacky Racers Robotic Racing Series in collaboration with #PiWars. Find out more and register your inter…
Oct 23, 2022
DIY Robocars via Twitter
RT @Hacky_Racers: There will be three classes at this event: A4, A2, and Hacky Racer! A4 and A2 are based around UK paper sizing and existi…
Oct 23, 2022
DIY Robocars via Twitter
Oct 23, 2022
DIY Robocars via Twitter
Oct 19, 2022
DIY Robocars via Twitter
Oct 18, 2022
DIY Robocars via Twitter
RT @NeaveEng: Calling all UK based folks interested in @diyrobocars, @f1tenth, @donkey_car, and similar robot racing competitions! @hacky_r…
Oct 13, 2022
More…