IT Basic Wednesday 14 April 2010

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

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.
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Loops –Do while Do While Reading for this Lecture, L&L, 5.7.
Robotics Invention System 2.0
Building robots Spring Mindstorms Programming Java + leJOS, NQC, and others.
The Turtle Laboratory Sequence LMICSE Workshop August , 2006 Villanova University.
Using LeJOS LMICSE Workshop August , 2006 Villanova University.
Using LeJOS LMICSE Workshop June , 2005 Alma College.
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
Programming Part 1 Armond R. Smith Zhenying Wu. Overview of this Class ● Transition from FTC -> FRC ● Using Your Resources ● Java Keywords o Data Types.
Shorthand operators.
Java for Robots How to program an NXT robot with a Java Brain Bert G. Wachsmuth Seton Hall University.
LEGO NXT Robot Programming Introduction to Programming a Lego NXT robot in Java.
Set up the Environment for leJOS NXJ. Required Software Software –JDK 1.6 –leJOS NXJ –USB driver for NXT Mindstorm nxt USB driver Libusb MMN Lab.
Georgia Institute of Technology Speed part 3 Barb Ericson Georgia Institute of Technology May 2006.
Interfacing the LEGO RCX to the outside world John M. Larkin Whitworth College Spokane, WA.
1 CS 177 Week 5 Recitation Slides Loops. 2 Announcements Project 2 due next Thursday at 9PM. Exam 1 this evening (switch and loop not covered) Old exams.
T HE F INCH R OBOT AND THE W HILE L OOP Pepper. T HE R OBOT Developed by Carnegie Mellon students to teach CS Supports many compilers, including Java.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
JAVA COURSE LESSON2 BY OMPUTER ENGINEEING ASSOCIATION.
Mixing integer and floating point numbers in an arithmetic operation.
Event Driven Programming Minus the GUI Plus a Robot By Charlie Vick.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4.
CSE 1341 Honors Professor Mark Fontenot Southern Methodist University Note Set 11.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
CS101: Introduction to Computer Science Slides adapted from Sedgewick and Wayne Copyright © Your First Java.
Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room.
Week 14 - Monday.  What did we talk about last time?  Inheritance.
CS7 Recitation Cem Akkaya. Outline  Homework-0 in detail  Useful links and tools  Setting up your java environment.
Building robots Spring Building Braitenberg Vehicles From Abstraction to Realization.
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
ECE 002 Robots and Sensors Group 14. Objectives Research sensors and their usefulness to analyze data Research sensors and their usefulness to analyze.
Programming with LabVIEW Intro to programming and.
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 6_1 GEORGE KOUTSOGIANNAKIS Copyright: FALL 2015 Illinois Institute of Technology- George Koutsogiannakis 1.
TOPIC 8 MORE ON WHILE LOOPS 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson,
Exceptions and Error Handling. Exceptions Errors that occur during program execution We should try to ‘gracefully’ deal with the error Not like this.
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
Comp1004: Introduction III Java. Content How Java Works: The JVM Writing a Class in Java – Class – Member Variables – Method – Statement Magic incantations.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4.
Introduction to Programming in RobotC
Computer Programming Your First Java Program: HelloWorld.java.
Eclipse.
Introduction to Java Import Scanner class to use in our program
using System; namespace Demo01 { class Program
MINDSTORMS NXT with JAVA
Eclipse Navigation & Usage.
USING ECLIPSE TO CREATE HELLO WORLD
Week 14 - Wednesday CS 121.
CompSci 230 Software Construction
Repetition.
The Finch Robot and the While Loop
LRobot Game.
An Introduction to Java – Part I, language basics
COMPUTER 2430 Object Oriented Programming and Data Structures I
Game Controller Lesson Three.
Tonga Institute of Higher Education
Exercise 11.1 Write a code fragment that performs the same function as the statement below without using the crash method Toolbox.crash(amount < 0,
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 5.
class PrintOnetoTen { public static void main(String args[]) {
Programming - Buttons Intro to Robotics.
Which way does the robot have to turn to get to the charger?
Programming - Buttons Intro to Robotics.
Truth tables: Ways to organize results of Boolean expressions.
More on Creating Classes
Introduction to Computer Science I.
The for-statement.
LEGO Mindstorms Robot and Java
Introduction to java Part I By Shenglan Zhang.
The beginning of media computation Followed by a demo
Presentation transcript:

IT Basic Wednesday 14 April 2010 27. august 2018 IT Basic Wednesday 14 April 2010 Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk Hanne Bundgaard

Agenda LeJOS and java elements Picking up blue or red balls Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk

Don’t forget the steps…. Eclipse New Java Project New Class Write the class Save Command Prompt Go to project folder (workspace\project\src) Compile the class (nxjc) Link and upload (nxj) Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk

The java class import lejos.nxt.*; public class HelloWorld { Class file must be named the same ( HelloWorld.java) import lejos.nxt.*; public class HelloWorld { public static void main (String[] aArg) throws Exception LCD.drawString("Hello World",3,4); Thread.sleep(2000); } Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk

The java class import lejos.nxt.*; public class HelloWorld { To use LeJOS we must import the tools This is where motors and sensors are defined import lejos.nxt.*; public class HelloWorld { public static void main (String[] aArg) throws Exception LCD.drawString("Hello World",3,4); Thread.sleep(2000); } Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk

The java class import lejos.nxt.*; public class HelloWorld { public static void main (String[] aArg) throws Exception LCD.drawString("Hello World",3,4); Thread.sleep(2000); } The main method must exist and is the starting method of your system Just write it this way Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk

The java class import lejos.nxt.*; public class HelloWorld { Sometimes exception handling is required – then add the throws exception to your method import lejos.nxt.*; public class HelloWorld { public static void main (String[] aArg) throws Exception LCD.drawString("Hello World",3,4); Thread.sleep(2000); } Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk

The java class import lejos.nxt.*; public class HelloWorld { public static void main (String[] aArg) throws Exception LCD.drawString("Hello World",3,4); Thread.sleep(2000); } In methods we execute statements Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk

For loop import lejos.nxt.*; public class TenCount { public static void main (String[] aArg) throws Exception for(int count=1; count<11; count++) LCD.drawString("Count is: " + i, 3, 4); Thread.sleep(1000); } Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk

while loop int count = 1; while (count < 11) { LCD.drawString("Count is: " + count, 3, 4); count++; Thread.sleep(1000); } Google: java while Count++ Is the same as Count = count+1 Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk

If statement if (bump.isPressed()) { right(); } else left(); Google: java if Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk

FollowLine so far import lejos.nxt.*; public class FollowLine { public static void main(String[] args) throws Exception LightSensor light = new LightSensor(SensorPort.S1); while (true) forward(); if (light.readValue() < 40) left(); } if (light.readValue() >= 40) right(); private static void forward() { Motor.A.forward(); Motor.C.forward(); } private static void left() throws Exception Motor.A.stop(); Thread.sleep(500); forward(); private static void right() throws Exception Motor.C.stop(); } //end class Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk

Exercise 1 Count to 10 If a button is pressed before 10, count backwards Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk

Exercise 2 Let your robot follow the line If it meets a red ball Write: ”Found red ball” in the display Pick it up Turn to the right Drop the ball If a button is pressed, pick up blue balls instead Technical Faculty - Campus Horsens, Henrik Kronborg Pedersen – hekp@viauc.dk