Learning C really fast A power point for Jay. RobotC vs C RobotC is slightly different than C We will cover standard C Then RobotC differences.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Introduction to C Programming
Pass by Value. COMP104 Pass by Value / Slide 2 Passing Parameters by Value * A function returns a single result (assuming the function is not a void function)
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Jason Howard. Agenda I. How to download robotc II. What is tele-op used for? III. How to build a basic tele-op program IV. Getting the robot to drive.
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
Programming III SPRING 2015 School of Computer and Information Sciences Francisco R. Ortega, Ph.D. McKnight Fellow and GAANN Fellow LECTURE #3 Control.
Team 5220 Roboknights. Outline  Getting Started  Hardware Setup/Wiring  Software Setup/Pragmas  Programming with RobotC  Grammar/Syntax  Basic Statements.
Chapter 7: User-Defined Functions II
Automation and Robotics
VEX and Robot C Chris Patterson Presented by Modified by J. Andazola.
V EX C OACHES ' T RAINING October 12, Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.
CS 201 Functions Debzani Deb.
Lecture 3 Strings More control statements C functions.
CS 117 Spring 2002 Review for Exam 2 March 6, 2002 open book, 1 page of notes.
RobotC For Beginners Tyler Lutz and Keaton Bonds DRSS Enterprise.
Functions in C. Function Terminology Identifier scope Function declaration, definition, and use Parameters and arguments Parameter order, number, and.
Testbed: Exercises.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
ROBOTC Software Introduction. ROBOTC Software ROBOTC developed specifically for classrooms and competitions Complete programming solution for VEX Cortex.
chipKit Sense Switch & Control LED
Weston Schreiber & Joshua Gabrielse Robotics Summer Training Programming #1: EasyC Basics.
C Programming Tutorial – Part I CS Introduction to Operating Systems.
Variables, Functions & Parameter Passing CSci 588 Fall 2013 All material not from online sources copyright © Travis Desell, 2011.
Monday, Jan 13, 2003Kate Gregory with material from Deitel and Deitel Week 2 Questions from Last Week Control Structures Functions Lab 1.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
Variable Scope Storage Class Recursion
How to Control a Robot Kickoff Why, How, Where? Sense, think, act Robot, laptop, your brain GameRobot Human Game State Score External Sensors Internal.
Agenda Review C++ Library Functions Review User Input Making your own functions Exam #1 Next Week Reading: Chapter 3.
EPSII 59:006 Spring Introduction to C More Administrative Details The C Programming Language How a computer processes programs Your first C program.
Scope: Portion of the program in which the identifier can be referenced. Various types of scope, my examples are of block scope and global scope.
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
Lecture 13: Working with Multiple Programmers. Headers Header files: Each standard library has a corresponding header. The function prototype for all.
Structure Programming Lecture 8 Chapter 5&6 - Function – part I 12 December 2015.
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
Session 12 Sensors and Timers. 3 Main Types of Robot Projects Command-Based Robot A more complicated project for more complicated robots Iterative Robot.
Teacher/Mentor Institute Using easyC David Dominguez June 2, 2015 Update Version.
Lecturer: Nguyen Thi Hien Software Engineering Department Home page: hienngong.wordpress.com Chapter 2: Language C++
COSC 1P02 Introduction to Computer Science 5.1 Cosc 1P02 Week 5 Lecture slides Psychiatrist to patient "You have nothing to worry about - anyone who can.
VEX and Robot C Chris Patterson Frisco ISD CTE Center Presented by.
 2003 Prentice Hall, Inc. All rights reserved. 1 Basic C++ Programming.
Array and Pointers An Introduction Unit Unit Introduction This unit covers the usage of pointers and arrays in C++
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
APS105 Functions (and Pointers) 1. Modularity –Break a program into manageable parts (modules) –Modules interoperate with each other Benefits of modularity:
Announcements. Practice questions, with and without solutions will be uploaded by Friday 5 th November, make sure to check them before the weekend \\netstorage\Subjects\ITCA-b\Exam.
Tarik Booker CS 242. What we will cover…  Functions  Function Syntax  Local Variables  Global Variables  The Scope of Variables  Making Functions.
Variable Scope. When you declare a variable, that name and value is only “alive” for some parts of the program  We must declare variables before we use.
Introduction to Programming in RobotC
Constructors and Destructors
User-Written Functions
Chapter 7: User-Defined Functions II
Suppose we want to print out the word MISSISSIPPI in big letters.
Robotics Programming Using Shaft Encoders
Student Book An Introduction
Movement using Shaft Encoders
By Willem Scholten Learning Access Institute
Automation and Robotics
Chapter 8 The Loops By: Mr. Baha Hanene.
Constructors and Destructors
Programming - Buttons Intro to Robotics.
Robotics Programming Using Shaft Encoders
Programming - Buttons Intro to Robotics.
Robotics Programming Using Shaft Encoders
Function.
Robotics Week 4 Functions and reusable code
Robotics Programming Using Shaft Encoders
Function.
Introduction to Programing the Cortex for BEST
Presentation transcript:

Learning C really fast A power point for Jay

RobotC vs C RobotC is slightly different than C We will cover standard C Then RobotC differences.

A normal simple C program #include void doSomething(int x); int main(void) { int countIndex = 0; for(countIndex = 0; countIndex<5; countIndex++) { if(3 != countIndex) { printf("Count:%d\n",countIndex); } else { doSomething(countIndex); } return 0; } void doSomething(int x) { printf("In Func:%d\n",x); }

#include This brings in other libraries. The libraries are the hardest part of C You need to know what is in each one and what it's named Just ignore this for now. This one is for the function “printf”

void doSomething(int x); Forward function declaration. It tells the compiler that somewhere in this file is a function called 'doSomething' The void tells the compiler nothing will be returned from this function (more on that to come). The 'int x' tells us that a number is going to be passed in. The forward declaration ends in a ';'

int main(void) This is the main function. This is where the program will begin. The function will return a number (int). The function does not have anything passed in (void).

int countIndex = 0; This is a variable. Its a label that holds 'stuff' The label is called 'countIndex'. The stuff is a number = 0. A int is a type of variable. It means a number from -2,147,483,648 to 2,147,483,647 Other type are char (-128 to 127), short (32,768 to -32,767) Just stick with int for numbers.

for(countIndex = 0; countIndex<5; countIndex++) For loop. It counts things. This one counts from 0 to 4. countIndex = 0 tells us where to start. countIndex<5 tells us to keep counting while countIndex is less than 5. countIndex++ means to add 1 to countIndex each time though the loop. for(countIndex = 1; countIndex<=10; countIndex+=2) Counts from 1 to 10 by 2s

if(3 != countIndex) The If statement makes decisions This one says do the following if countIndex is not equal to 3. The 3 does not need to be first. != is not equal. Equal is == (note the double =). greater than. <= less than of equal to. && is AND, || is OR Complex: ((3 != countIndex) && (4 == somethingElse)) If countIndex is not 3 and somethingElse is 4

printf("Count:%d\n",countIndex); The printf statement prints stuff out. The %d says print a number at this point. The \n says print a new line. The %d corresponds to countIndex. The %d match to the parameters after the “ “. printf(“Count:%d %d\n”,countIndex,somethingElse); The the first %d would print countIndex, the second %d would print somethingElse.

else The else is the other half of the 'if' statement. In our case it's 3 == countIndex. Note the '{' and '}'. The braces tell the compiler that this is a block of code and goes with either the function, for loop, if statement or else statement.

doSomething(countIndex); Call the function and pass in countIndex. If doSomething returned a value the statement would be: somethingElse = doSomething(countIndex);

return 0; Return a number to the next 'level' up. This just returns a number '0'. Could pass back a variable: return countIndex;

void doSomething(int x) { This is the body of the function doSomething. Note this does not have a ';' and it is followed by a body '{' '}'

printf("In Func:%d\n",x); Another print statement.

RobotC RobotC is based on C Short cut things are added that 'hide' a bunch of things and make it complex to code in.

RobotC is wierd The Function Library takes care of your 'include' lines so you don't need to include all the libraries.

#pragma config(Motor, motor6, rightMotor, tmotorVexIQ, openLoop, encoder) This really just defines a variable. Its a type of 'Motor' It connects motor6 to a variable called rightMotor. It's based on a tmotorVexIQ (just copy this, we don't need to worry about this). Its a openLoop and has a encoder, again don't worry about this right now.

#pragma config(Motor, motor1, leftMotor, tmotorVexIQ, openLoop, reversed, encoder) The same as the last slide, but with reversed in it.

setMotorSpeed(leftMotor, getJoystickValue(ChA)); setMotorSpeed(rightMotor, getJoystickValue(ChD)); Two joystick drive. (Tank drive) SetMotorSpeed is a global function. leftMotor/rightMotor are variables defined from that '#param' call. getJoystickValue is a global function as well. 'ChA' is a constant value. Like a variable that can't be changed. It tells getJoystickValue which joystick to look at.

setMotorSpeed(leftMotor, (getJoystickValue(ChA) - getJoystickValue(ChB))/2); setMotorSpeed(rightMotor, (getJoystickValue(ChA) + getJoystickValue(ChB))/2); Standard turn the joystick into a single joystick drive. I've never really sat down to look at it, I've just copied it into my code.

#pragma config(Motor, motor10, armMotor, tmotorVexIQ, openLoop, encoder) In Vex a motor can be a continuous rotation or a airplane servo. I think this is odd, I would have guessed they are different somehow. You need to know what type of motor it is to use the right global functions.

resetMotorEncoder(armMotor); //Take current position as zero. setServoTarget(armMotor, 300); //Enable Servo Mode and move to position 60. The global functions for dealing with a Servo. I'm not sure how these work, you will have to test them out.

#pragma config(Sensor, port5, colorDetector, sensorVexIQ_Color12Color) Defining a sensor. Its a Sensor, not a Motor It's on port5 and named colorDetector. It's a type of sensorVexIQ_Color12Color. This line is another just use it as is line. At this point you don't need to worry about it.

getColorName(colorDetector) != colorGreen getColorName is the global function colorDetector is the sensor we just defined. colorGreen is a constant.