Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

Version 1 Current »

Objective

This tutorial is more of a presentation to show how to go from a robot design to a CrcDuino code capable of performing sequential actions. The relatable and simple example used is based on the 2020-11-23 webinar on Autonomous robot design.

Before looking at tutorial 11, watch the Autonomous Robot Design Webinar.

Diagrams

Video presentation

DaveExpliqueCommentPasserDuDiagramme2ADuCode.mp4

Code

Download the Arduino IDE .ino file:

This is a transcript of the code:

//***************************************************************************
// This code accompanies the Cereal box example in the 2020-11-23 Robot Design Webinar
//***************************************************************************
#include <CrcLib.h>

//Step management variable declaration
bool step0 = LOW;
bool step1 = LOW;
bool step2 = LOW;
bool step3 = LOW;
bool step4 = LOW;
bool step5 = LOW;
bool step6 = LOW;

//***************************************************************************
void setup() {
  CrcLib::Initialize();
  
  //We want to be in step0 upon startup
  step0 = HIGH; step1 = LOW; step2 = LOW; step3 = LOW; step4 = LOW; step5 = LOW; step6 = LOW;
}
//***************************************************************************
void loop() {
  CrcLib::Update();

      //------------------
      if(step0 == HIGH)
      {
          //The action you want to execute during step0 goes here
          // "DO NOTHING" 
          
          if( true ) // Replace "true" by the condition representing transition 0-1
          {
              //...we change the steps configuration to take another if() statement during the next scans
              step0 = LOW; step1 = HIGH; step2 = LOW; step3 = LOW; step4 = LOW; step5 = LOW; step6 = LOW;
          }
      }
      //------------------
      if(step1 == HIGH)
      {
        //The action you want to execute during step1 goes here
    
        if( true )  // Replace "true" by the condition representing transition 1-2
        {
          //...we change the steps configuration to take another if() statement during the next scans
          step0 = LOW; step1 = LOW; step2 = HIGH; step3 = LOW; step4 = LOW; step5 = LOW; step6 = LOW;
        }
      }
      //------------------
      if(step2 == HIGH)
      {
        //The action you want to execute during step2 goes here
    
        if( true )  // Replace "true" by the condition representing transition 2-3
        {
          //...we change the steps configuration to take another branch ( if() statement ) during the next scans
          step0 = LOW; step1 = LOW; step2 = LOW; step3 = HIGH; step4 = LOW; step5 = LOW; step6 = LOW;
        }
      }
      //------------------
      // 
      //And so on for Step 3, 4 and 5
      //
      //------------------
      
      if(step6 == HIGH)
      {
        //Do nothing in Step 6

        //We want to stay here forever (until the CrcDuino is shut down), so don't update memory
      }


}
  • No labels