Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro C++ Programming WINDSOR-ESSEX FIRST ROBOTICS WWW.WINDSORESSEXFIRST.ORG.

Similar presentations


Presentation on theme: "Intro C++ Programming WINDSOR-ESSEX FIRST ROBOTICS WWW.WINDSORESSEXFIRST.ORG."— Presentation transcript:

1 Intro C++ Programming WINDSOR-ESSEX FIRST ROBOTICS WWW.WINDSORESSEXFIRST.ORG

2 What will we cover today Understanding the sample code Understanding of basic C++ operations and data structures Resources for continued learning

3 Technical Resources The FRC website has GREAT resources for this years new hardware. ◦https://wpilib.screenstepslive.com/s/4485https://wpilib.screenstepslive.com/s/4485 ◦Covers Labview, C++, and Java

4 More Resources Chief Delphi http://www.chiefdelphi.com/forums/portal.php Great resource – A forum with other FRC students, sharing and answering questions

5 Sample C++ Code

6 Variables A variable is a container for data that needs to be used for other steps. Int, Float, Boolean are simple data variables RobotDrive, Joystick are complex objects. These objects store lots of data in a known structure.

7 Sample C++ Code Functions Contain code that can be easily called by other code If a section of code will be reused in more than one place, a function is an easy way to keep your code organized, as well as easy to change in the future

8 Sample C++ Code Loops A code loop will loop until conditions are no longer met. In this case, we will loop through the tele operated code until we are no longer Enabled or In Tele Operated Mode.

9 Sample C++ Code Object Structures - RobotDrive RobotDrive is a data structure that contains both variables and functions In C++ these variables and functions can be accessed using the “.” or “->” to refer to an objects structure. Example myDrive.arcadeDrive(driveStick)

10 Sample C++ Code Object Structures Jaguar *exampleJaguar = new Jaguar(0); exampleJaguar->Set(0.7); gyro = new Gyro(1); double angle = gyro.getAngle();

11 C++ Coding – Your Turn #include using namespace std; int main () { int i; cout << "Please enter an integer value: "; cin >> i; cout << "The value you entered is " << i; cout << " and its double is " << i*2 << ".\n"; return 0; }

12 C++ Coding – Your Turn #include using namespace std; int addition (int a, int b) { int r; r=a+b; return r; } int main () { int z; z = addition (5,3); cout << "The result is " << z; }

13 C++ Coding – Get Some Class #include using namespace std; class Rectangle { int width, height; public: void set_values (int,int); int area() {return width*height;} }; void Rectangle::set_values (int x, int y) { width = x; height = y; } int main () { Rectangle rect; rect.set_values (3,4); cout << "area: " << rect.area(); return 0; }

14 Setting Up a New Project https://wpilib.screenstepslive.com/s/4485/m/13810/l/145319-creating-your- benchtop-test-program


Download ppt "Intro C++ Programming WINDSOR-ESSEX FIRST ROBOTICS WWW.WINDSORESSEXFIRST.ORG."

Similar presentations


Ads by Google