The George Washington University Department of ECE ECE 001 - Intro: Electrical & Computer Engineering Intro to the Robotics Introducing the IC Discuss.

Slides:



Advertisements
Similar presentations
Programming In C++ Spring Semester 2013 Lecture 3 Programming In C++, Lecture 3 By Umer Rana.
Advertisements

Lecture 2 Introduction to C Programming
Introduction to C Programming
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
Dr. Yang, Qingxiong (with slides borrowed from Dr. Yuen, Joe) LT4: Control Flow - Loop CS2311 Computer Programming.
CMT Programming Software Applications
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 8 - Interest Calculator Application: Introducing.
PHYS 2020 Making Choices; Arrays. Arrays  An array is very much like a matrix.  In the C language, an array is a collection of variables, all of the.
Introduction to C Programming
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 1Winter Quarter Stop Light Lab 7.
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.
CS140: Intro to CS An Overview of Programming in C by Erin Chambers.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Variables 1.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class 2.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 3.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering –Intro to the Robotics –Introducing the IC –Discuss.
The George Washington University Department of ECE ECE 1010 Intro: Electrical & Computer Engineering –Introducing KIPR Link/Interface and Set-up –Continuation.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4.
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
1 Homework Done the reading? –K&R –Glass Chapters 1 and 2 Applied for cs240? (If not, keep at it!) Gotten a UNIX account? (If not, keep at it!)
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4/Lab3.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class3/Lab 2.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
BY ILTAF MEHDI (MCS, MCSE, CCNA)1. INSTRUCTOR: ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) BY ILTAF MEHDI (MCS, MCSE, CCNA)2 Chapter No: 04 “Loops”
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
The George Washington University Electrical & Computer Engineering Department Dr. S. Ahmadi Class 3.
C Language 1 Program Looping. C Language2 Topics Program looping Program looping Relational operators / expressions Relational operators / expressions.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 The George Washington University Electrical & Computer Engineering Department ECE 1010 Intro To Electrical and Computer Engineering Dr. S. Ahmadi Class.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4.
Topic 02: Introduction to ActionScript 3.0
Whatcha doin'? Aims: To start using Python. To understand loops.
Chapter 1: Introduction to computers and C++ Programming
CSE 220 – C Programming C Fundamentals.
Chapter 2 - Introduction to C Programming
Lecture 7: Repeating a Known Number of Times
2.5 Another Java Application: Adding Integers
Chapter 2 Assignment and Interactive Input
Stop Light Lab 7 Winter Quarter.
Variables, Expressions, and IO
Introducing KIPR Link/Interface and Set-up
Chapter 2 - Introduction to C Programming
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Arrays, For loop While loop Do while loop
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
CS1100 Computational Engineering
Chapter 2 - Introduction to C Programming
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 5.
Chapter (3) - Looping Questions.
T. Jumana Abu Shmais – AOU - Riyadh
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4.
File I/O in C Lecture 7 Narrator: Lecture 7: File I/O in C.
Chapter 2 - Introduction to C Programming
Homework Applied for cs240? (If not, keep at it!) 8/10 Done with HW1?
Programming - Buttons Intro to Robotics.
Programming - Buttons Intro to Robotics.
Programs written in C and C++ can run on many different computers
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4.
Chapter 2 - Introduction to C Programming
Introduction to C Programming
Presentation transcript:

The George Washington University Department of ECE ECE 001 - Intro: Electrical & Computer Engineering Intro to the Robotics Introducing the IC Discuss motor control using IC Hands-on programming Dr. S. Ahmadi Class 1 Slides obtained from Botball Kit Documentation

Class Outline Policy and Safety Basic IC programming Download Display Function commands Botball Part list https://blogs.gwu.edu/ece1010/course-material • Overview of Motors

How to Write a SIMPLE Interactive C (IC) Computer Program IC is a hybrid of C designed to run on small, self-contained robot controllers int main() { return 0; } Making decisions If ( ) { statement } Else( ) { statement } Making repeated decisions While( ) { statement }

How to Write a SIMPLE Interactive C (IC) Computer Program IC is a hybrid of C designed to run on small, self-contained robot controllers int main() { // This is a comment int my_variable; // “my_variable” is of type: integer my_variable = 2; // assinging a variable motor(1, my_variable); // a function call, turns on motor float my_second_variable; // “my_second_variable” is of type: float my_second_variable = 2+(3/6)^5; // mathematical expression using C my_second_variable = sqrt((a^2)+(b^2)); return 0; // exit code meaning the program has terminated // successfully } Important: All statements end with a semicolon (;). Making decisions If ( ) { statement } Else( ) { statement } Making repeated decisions While( ) { statement }

Variable Types What is a variable? It holds information, for example: a number Two types of variables we will use in ECE001 int (16 bit integer number in IC) +/-32,767 (largest # it can hold) float (32 bit floating point number) e.g. 3.1416

Sleep(seconds); Useful Function: sleep() delays the function’s execution for an amount of time equal to the number of seconds (expressed as a float) given as an argument

printf(“I’m printing\n”); C Function: printf(); Takes a quoted string and prints it out – %d is used for an integer – %f is used for a float – \n starts next character back at upper left corner (or new line on terminal) – commas separate all arguments after the quoted string printf(“I’m printing\n”);

Handyboard Functions a_button(); b_button(); c_button(); beep(); fd(x); // makes motor “x” go forward bk(x); // makes motor “x” go backward ao(); // turns all motors off --- “all off”

Sample Program When a program is run, the control moves from one statement to the next Calculate j2 + 1 when j = 3 int main() { int r,j; /* declare r and j */ j = 3; /* assign a value to j */ r = j*j + 1; /* calculate and assign */ printf(“result is %d\n”,r); return 0; }

Making decision Using if-else condition int main() { if ( start_button()==1) { fd(1); fd(2); } else { ao(); } return 0; }

Repeating Execution: Loops Loops are used when you want to do the same thing multiple times E.g., beep 20 times You could type beep(); 20 times, but there is a better way: a loop

Repetition Using while Syntax: while (<test>) {statements} Beep 20 times int main() { int num; /* declare counter */ num = 1; /* initialize counter */ while (num <= 20) /* loop while num is <=20*/ beep(); /* beep once */ num = num + 1; /* add one to the counter */ } return 0;

Get Started with IC Environment Start the IC application Click on the picture of the Handy Board Click on the Connect Later button Click on the New button (upper left corner) Type in the program that prints out a text string Save the file using the Save button (name it whatever you want -- just remember where you put it).

Important Information How to learn IC programming http://www.kipr.org/curriculum/programming.html Check class website for Handy board documentation Check IC command functions Check the handy board diagram Return the Kit release form after you check all parts in the Kit Homework is to be done individually