Skip to content

Instantly share code, notes, and snippets.

@Inkering
Created October 4, 2019 14:58
Show Gist options
  • Save Inkering/c07007ea90642a7e1754ec8341e044b3 to your computer and use it in GitHub Desktop.
Save Inkering/c07007ea90642a7e1754ec8341e044b3 to your computer and use it in GitHub Desktop.

Revisions

  1. Inkering created this gist Oct 4, 2019.
    32 changes: 32 additions & 0 deletions struct-test.ino
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    struct Speeds {
    // struct
    int left;
    int right;
    };

    Speeds new_speed;
    Speeds last_speed;

    Speeds PID(int leftSensor, int rightSensor) {
    // create a new set of speeds
    Speeds motorSpeeds;

    // default speed
    motorSpeeds.left = 80;
    motorSpeeds.right = 80;

    // pid loop here!

    // return the calculated speeds
    return motorSpeeds;
    }


    // the setup function runs once when you press reset or power the board
    void setup() {
    }

    // the loop function runs over and over again forever
    void loop() {
    new_speed = PID(1,2);
    }