SlideShare a Scribd company logo
1 of 99
Oracle IoT Kids Workshop
Stephen Chin
Java Technology Ambassador
JavaOne Content Chair
@steveonjava
What Runs Java?
What Runs Java?
Java and 3G in a Tiny Package
> Cinterion EHS5
Really Tiny…
27.6mm
18.8mm
http://upload.wikimedia.org/wikipedia/commons/3/3d/Cloud_forest_Ecuador.jpg
=
Have Java With Your Dessert
Raspberry Pi
Pis are Affordable
$35
Pis are Affordable
$35 1 Box of Diapers
Bicycle
(but just 1 wheel)
A Cake
Chalkboard Electronics Touchscreen
 10" or 7" Form Factor
 Connects via HDMI/USB
 Tested with JavaFX 8
 10% Exclusive Discount:
G1F0U796Z083
How to Setup Your Pi
> Step 1: Install Linux
> Step 2: Download/Copy Java 8 for ARM
> Step 3: Deploy and Run JVM Language Apps
http://steveonjava.com/
javafx-on-raspberry-pi-3-easy-steps/
Electronic Safety!
> Unplug from wall before wiring
> Get rid of static by touching a metal
surface
> Don't touch exposed wires/metal
> Never remove/insert SD Card while
power is on
12
What Comes in Your Lab Kit
1. Touch Screen
2. SD Card
3. Keyboard
4. Yellow Box:
 Power Adapter
 LVDS Cable/Board
 Raspberry Pi Model B
 Mini-USB Cable (power)
Please Save All the Packaging for Later
Hooking Up the Pi (Part A)
1. Insert the SD Card in to the Pi
 Will appear upside down when looking at the top
of your Pi
2. Insert the HDMI board into the Pi's HDMI
jack
3. Connect the Pi power to the HDMI board
 Use the Micro USB Cable (short one)
14
Important: Connect everything before plugging into the wall
Hooking Up the Pi (Part B)
4. Slide the LCD cable into the back of the display
 Side with gold connectors goes up
 Be careful, the connector is fragile!
5. Hook up the USB keyboard
6. Connect the USB end to one of the Pi's USB host ports
 This provides touch input
15
Verify connections and plug into power now
Is it Working?
> Should get a bunch of flashing LEDs to indicate booting
 Boot takes approx 30 seconds
> The LCD screen should light up
 Might be dim if the light sensor is obstructed
> And you will should see a Linux boot screen with lots of text
Logging In
At the login prompt type your username:
> pi
And enter the password:
> raspberry
Running the JavaFX Sample Application
Change directory to the project folder
> cd MaryHadALittleLambda
Run the build script
> ant
19
Hacking the Code
Run the nano text editor:
> nano src/sample/MapObject.java
Save your changes:
> Control-O Enter
Exit Nano:
> Control-X
Compile/Run:
> ant
Mary Had a Little Lambda
Mary had a little lambda
Whose fleece was white as snow
And everywhere that Mary went
Lambda was sure to go!
https://github.com/steveonjava/MaryHadALittleLambda
Generating Streams
From a collection:
> anyCollection.stream();
Known set of objects:
> Stream.of("bananas", "oranges", "apples");
Numeric range:
> IntStream.range(0, 50)
Iteratively:
> Stream.iterate(Color.RED,
> c -> Color.hsb(c.getHue() + .1, c.getSaturation(),
> c.getBrightness()));
22
Let's Create Some Barn Animals!
SpriteView tail = s.getAnimals().isEmpty() ?
s : s.getAnimals().get(s.getAnimals().size() - 1);
Stream.iterate(tail, SpriteView.Lamb::new)
.skip(1).limit(7)
.forEach(s.getAnimals()::add);
23
24
Filtering Streams
Predicate Expression
> public interface Predicate<T> {
> public boolean test(T t);
> }
Filter out minors
> adults = attendees.filter(a -> a.getAge() >= 1.8)
25
Rainbow-colored Lambs!
s.getAnimals().stream()
.filter(a -> a.getNumber() % 4 == 2)
.forEach(a -> a.setColor(Color.YELLOW));
s.getAnimals().stream()
.filter(a -> a.getNumber() % 4 == 3)
.forEach(a -> a.setColor(Color.CYAN));
s.getAnimals().stream()
.filter(a -> a.getNumber() % 4 == 0)
.forEach(a -> a.setColor(Color.GREEN));
26
27
Filtering Collections
Collection.removeIf
> Removes all elements that match the predicate
List.replaceAll
> In-place filtering and replacement using an unary operator
ObservableCollection.filtered
> Returns a list filtered by a predicate this is also Observable
28
Picky Eaters…
Predicate<SpriteView> pure =
a -> a.getColor() == null;
mealsServed.set(mealsServed.get() +
s.getAnimals().filtered(pure).size()
);
s.getAnimals().removeIf(pure);
29
30
Mapping Streams
Applies a Map Function to each element:
> Function<? super T, ? extends R>
Result: List is the same size, but may be a different type.
31
Single Map
s.getAnimals().setAll(s.getAnimals()
.stream()
.map(sv -> new Eggs(sv.getFollowing())
.collect(Collectors.toList())
);
32
Or a Double Map!
s.getAnimals().setAll(s.getAnimals()
.stream()
.map(SpriteView::getFollowing)
.map(Eggs::new)
.collect(Collectors.toList())
);
33
34
Flat Map
Applies a One-to-Many Map Function to each element:
> Function<? super T, ? extends Stream<? extends R>>
And then flattens the result into a single stream.
Result: The list may get longer and the type may be different.
35
Hatching Eggs
s.getAnimals().setAll(s.getAnimals()
.stream()
.flatMap(SpriteView.Eggs::hatch)
.collect(Collectors.toList())
);
36
37
Reduce
Reduces a list to a single element given:
> Identity: T
> Accumulator: BinaryOperator<T>
Result: List of the same type, but only 1 element left.
38
And the (formerly little) Fox ate them all!
Double mealSize = shepherd.getAnimals()
.stream()
.map(SpriteView::getScaleX)
.reduce(0.0, Double::sum);
setScaleX(getScaleX() + mealSize * .2);
setScaleY(getScaleY() + mealSize * .2);
shepherd.getAnimals().clear();
39
40
Mary Had a Little Lambda Project
> Open-source project to demonstrate lambda features
> Visual representation of streams, filters, and maps
41
https://github.com/steveonjava/MaryHadALittleLambda
Stuff to do…
> Changes to MaryHadALittleLambda:
 Change the number of sheep
 Make the rainbow have different colors
 Change the fox size to be fatter/skinnier
 Add new graphics (additional image files under images/extra)
42
camel.png lion.png greendragon.png cow.png Brownbear.png
Stephen Chin
tweet: @steveonjava
blog: http://steveonjava.com
nighthacking.com
Real Geeks
Live Hacking
NightHacking Tour
Hacking Time!
GPIO access
Wiring LEDs
> Wire the elements in
series:
 Connect the long end
of the LED to GPIO
 Connect the short end
of the LED to the
resistor
 Connect the resistor
to Ground
45
To GPIO To Ground
Using a Breadboard
> Pins are connected
horizontally in the center
> The edges are connect
vertically
> No current passes the
center line
46
Pi Cobbler
> Connects your Pi to the
Breadboard
> The white line is Pin 1
> Connect it in the center
top of your Breadboard
47
Pi4J
> The samples are located in
/opt/pi4j/examples
> Compile the samples by typing "./build"
> Instructions for running the samples are
printed out at the end of the build
> Pi4j needs root access to use GPIO (use
"sudo")
48
ControlGpioExample
49
> Demonstrates Controlling Pins:
 pin.low()
 pin.toggle()
 pin.pulse(duration, blocking)
> Try creating your own pattern!
sudo java -classpath .:classes:/opt/pi4j/lib/'*' BlinkGpioExample
Wiring Buttons
> Connect a circuit
across two legs
> While the button is
pressed…
 The legs numbered 1
and 2 are connected
 The legs numbered 3
and 4 are connected
50
ListenGpioExample
51
> Demonstrates Listening to a pin:
 addListener(pinListener)
> Change the message/action when
a button is pressed!
sudo java -classpath .:classes:/opt/pi4j/lib/'*' ListenGpioExample
BlinkGpioExample
52
> Use LEDs and Buttons together!
sudo java -classpath .:classes:/opt/pi4j/lib/'*' BlinkGpioExample
Stephen Chin
tweet: @steveonjava
blog: http://steveonjava.com
nighthacking.com
Real Geeks
Live Hacking
NightHacking Tour
Hacking Time!
LeJOS
How it works on the EV3
The Heart of the EV3
> TI Sitara AM1808
 ARM9, 300Mhz
> 64MB RAM / 16MB Flash
> Analog to Digital Converter
> 4 Motor Ports
> 4 Sensor Ports
> Bluetooth / USB
> MicroSD
EV3 Motors
EV3 Sensors
Color and Light Sensor
High frequency
sound waves
Measuring mode Vs Presence Mode
Ultrasonic Sensor
Infrared Sensor
Remote Control
Getting Started with LeJOS
> Micro SD Card (> 2GB)
> Compatible WIFI adapter
 NetGear WNA1100
 EDIMAX EW-7811Un
> Linux (or a Linux VM)
> Details here:
Creating Your SD Card
http://sourceforge.net/p/lejos/wiki/Home/
Lego Duke Segway
Bluetooth Pairing
> Make sure your Lego is turned on
> Open "Devices and Printers" from the
Start menu
> Click "Add a device"
> Select the Lego brick
> After pairing, right click on the new
device and choose "Connect using" >
"Access point"
Eclipse Setup
> Open Eclipse
> Go to "Preferences"
> Click on leJOS EV3
> Change the brick name to
"10.0.1.1"
65
Creating a New LeJOS Project
> Go to "File" > "New" > "Project…"
> Choose a LeJOS EV3 Project
66
Create a Class File
> Create a new class ("File" > "New"
> "Class")
> Give it a package (e.g. sample)
> Give it a name (e.g. LCDTest)
67
Simple LeJOS Application
import lejos.nxt.Button;
import lejos.nxt.LCD;
public class EV3FirstProgram {
public static void main(String[] args) {
LCD.clear();
LCD.drawString("First EV3 Program", 0, 5);
Button.waitForAnyPress();
LCD.clear();
LCD.refresh();
}
}
Stephen Chin
tweet: @steveonjava
blog: http://steveonjava.com
nighthacking.com
Real Geeks
Live Hacking
NightHacking Tour
Hacking Time!
Parts you will need Step 1
Assemble Brace
Step 2 Completed Brace
Assemble Brace
Parts you will need Step 1
Build Base
Step 2 Completed Base
Build Base
Motor parts Snap them on partially
Assemble Motor
Take motor and base And connect them like this
Assemble Motor
Foot parts Step 1
Add a Foot
Step 2 Add the Foot to the Base
Add a Foot
Assembled Foot and Base
Add a Foot
Lock parts Partially insert the red attachers
Add a Lock
Attach the lock Push down the red attachers to secure
Add a Lock
Tower parts Step 1 – push the rod all the way through
Construct the Tower
Step 2 Attach the Tower to the Base
Construct the Tower
Completed Tower
Construct the Tower
Fan Motor parts Step 1
Build the Fan Motor
Completed Fan Motor
Build the Fan Motor
Light Sensor parts Step 1
Construct the Light Sensor
Completed Light Sensor
Construct the Light Sensor
Fan Blade parts Step 1
Assemble the Fan Blades
Fan Blade, Light Sensor, and Fan Motor Completed Fan
Assemble the Fan
Assembled Wind Turbine
90
Wind Turbine Wiring
> Port A – Medium Moto
 Power Fan
> Port B – Large Motor
 Rotate Wind Turbine
> Port 1 – Light Sensor
 Track Ambient Light
91
Gear Box parts Step 1
EC: Gear Box Construction
Completed Fan with Gear Box
EC: Gear Box Construction
Making the Wind turbine turn
public class WindTurbine {
public static void main(String[] args) {
EV3MediumRegulatedMotor fan =
new EV3MediumRegulatedMotor(MotorPort.A);
fan.setSpeed(1500);
fan.setAcceleration(150);
fan.backward();
Delay.msDelay(10000);
}
}
Making the Tower spin
public class WindTurbine {
public static void main(String[] args) {
EV3LargeRegulatedMotor base =
new EV3LargeRegulatedMotor(MotorPort.B);
base.setSpeed(80);
base.rotateTo(-90);
base.rotateTo(90);
}
}
Checking the Ambient Light
public class WindTurbine {
public static void main(String[] args) {
EV3ColorSensor light =
new EV3ColorSensor(SensorPort.S1);
float[] sample = new float[1];
SensorMode mode = light.getAmbientMode();
mode.fetchSample(sample, 0);
LCD.drawString("Light = " + sample[0], 0, 4);
Delay.msDelay(5000);
}
}
Putting it all together…
> Can you write a program that will:
1. Rotate the fan in a circle
2. Check the ambient light while rotating
3. Move back to the brightest angle
4. Spin the fan
http://commons.wikimedia.org/wiki/Wind_generator#mediaviewer/File:Eolienne_et_centrale_thermique_Nuon_Sloterdijk.jpg
Stephen Chin
tweet: @steveonjava
blog: http://steveonjava.com
nighthacking.com
Real Geeks
Live Hacking
NightHacking Tour
Safe Harbor Statement
The preceding is intended to outline our general product
direction. It is intended for information purposes only, and
may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality,
and should not be relied upon in making purchasing
decisions. The development, release, and timing of any
features or functionality described for Oracle’s products
remains at the sole discretion of Oracle.

More Related Content

What's hot

Remote Notifications
Remote NotificationsRemote Notifications
Remote NotificationsJosef Cacek
 
Tensorflow + Keras & Open AI Gym
Tensorflow + Keras & Open AI GymTensorflow + Keras & Open AI Gym
Tensorflow + Keras & Open AI GymHO-HSUN LIN
 
The Ring programming language version 1.9 book - Part 56 of 210
The Ring programming language version 1.9 book - Part 56 of 210The Ring programming language version 1.9 book - Part 56 of 210
The Ring programming language version 1.9 book - Part 56 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 47 of 185
The Ring programming language version 1.5.4 book - Part 47 of 185The Ring programming language version 1.5.4 book - Part 47 of 185
The Ring programming language version 1.5.4 book - Part 47 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 50 of 196
The Ring programming language version 1.7 book - Part 50 of 196The Ring programming language version 1.7 book - Part 50 of 196
The Ring programming language version 1.7 book - Part 50 of 196Mahmoud Samir Fayed
 
DAHO.AM 2015 - Abusing phones to make the internet of things
DAHO.AM 2015 - Abusing phones to make the internet of thingsDAHO.AM 2015 - Abusing phones to make the internet of things
DAHO.AM 2015 - Abusing phones to make the internet of thingsJan Jongboom
 
The Ring programming language version 1.5.1 book - Part 45 of 180
The Ring programming language version 1.5.1 book - Part 45 of 180The Ring programming language version 1.5.1 book - Part 45 of 180
The Ring programming language version 1.5.1 book - Part 45 of 180Mahmoud Samir Fayed
 
Html5 game, websocket e arduino
Html5 game, websocket e arduinoHtml5 game, websocket e arduino
Html5 game, websocket e arduinomonksoftwareit
 
Html5 game, websocket e arduino
Html5 game, websocket e arduino Html5 game, websocket e arduino
Html5 game, websocket e arduino Giuseppe Modarelli
 

What's hot (11)

Remote Notifications
Remote NotificationsRemote Notifications
Remote Notifications
 
Tensorflow + Keras & Open AI Gym
Tensorflow + Keras & Open AI GymTensorflow + Keras & Open AI Gym
Tensorflow + Keras & Open AI Gym
 
The Ring programming language version 1.9 book - Part 56 of 210
The Ring programming language version 1.9 book - Part 56 of 210The Ring programming language version 1.9 book - Part 56 of 210
The Ring programming language version 1.9 book - Part 56 of 210
 
The Ring programming language version 1.5.4 book - Part 47 of 185
The Ring programming language version 1.5.4 book - Part 47 of 185The Ring programming language version 1.5.4 book - Part 47 of 185
The Ring programming language version 1.5.4 book - Part 47 of 185
 
The Ring programming language version 1.7 book - Part 50 of 196
The Ring programming language version 1.7 book - Part 50 of 196The Ring programming language version 1.7 book - Part 50 of 196
The Ring programming language version 1.7 book - Part 50 of 196
 
Kotlin Generation
Kotlin GenerationKotlin Generation
Kotlin Generation
 
DAHO.AM 2015 - Abusing phones to make the internet of things
DAHO.AM 2015 - Abusing phones to make the internet of thingsDAHO.AM 2015 - Abusing phones to make the internet of things
DAHO.AM 2015 - Abusing phones to make the internet of things
 
The Ring programming language version 1.5.1 book - Part 45 of 180
The Ring programming language version 1.5.1 book - Part 45 of 180The Ring programming language version 1.5.1 book - Part 45 of 180
The Ring programming language version 1.5.1 book - Part 45 of 180
 
Html5 game, websocket e arduino
Html5 game, websocket e arduinoHtml5 game, websocket e arduino
Html5 game, websocket e arduino
 
Gaming partye
Gaming partyeGaming partye
Gaming partye
 
Html5 game, websocket e arduino
Html5 game, websocket e arduino Html5 game, websocket e arduino
Html5 game, websocket e arduino
 

Similar to Oracle IoT Kids Workshop

MicroPython for LEGO Spike - introduction
MicroPython for LEGO Spike - introductionMicroPython for LEGO Spike - introduction
MicroPython for LEGO Spike - introductionsdoro58
 
TestowanieIoT2016
TestowanieIoT2016TestowanieIoT2016
TestowanieIoT2016kraqa
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
Sq lite python tutorial sqlite programming in python
Sq lite python tutorial   sqlite programming in pythonSq lite python tutorial   sqlite programming in python
Sq lite python tutorial sqlite programming in pythonMartin Soria
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnArnaud Joly
 
Exploring Thermal Related Stuff in iDevices using Open-Source Tool
Exploring Thermal Related Stuff in iDevices using Open-Source ToolExploring Thermal Related Stuff in iDevices using Open-Source Tool
Exploring Thermal Related Stuff in iDevices using Open-Source ToolKoan-Sin Tan
 
The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196Mahmoud Samir Fayed
 
iOS Automation Primitives
iOS Automation PrimitivesiOS Automation Primitives
iOS Automation PrimitivesSynack
 
Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016Mikhail Sosonkin
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 27 of 184
The Ring programming language version 1.5.3 book - Part 27 of 184The Ring programming language version 1.5.3 book - Part 27 of 184
The Ring programming language version 1.5.3 book - Part 27 of 184Mahmoud Samir Fayed
 
Eclipse Summit Europe '10 - Test UI Aspects of Plug-ins
Eclipse Summit Europe '10 - Test UI Aspects of Plug-insEclipse Summit Europe '10 - Test UI Aspects of Plug-ins
Eclipse Summit Europe '10 - Test UI Aspects of Plug-insTonny Madsen
 
pcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunJingfeng Liu
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCanSecWest
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindAndreas Czakaj
 

Similar to Oracle IoT Kids Workshop (20)

MicroPython for LEGO Spike - introduction
MicroPython for LEGO Spike - introductionMicroPython for LEGO Spike - introduction
MicroPython for LEGO Spike - introduction
 
TestowanieIoT2016
TestowanieIoT2016TestowanieIoT2016
TestowanieIoT2016
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
Sq lite python tutorial sqlite programming in python
Sq lite python tutorial   sqlite programming in pythonSq lite python tutorial   sqlite programming in python
Sq lite python tutorial sqlite programming in python
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
 
Exploring Thermal Related Stuff in iDevices using Open-Source Tool
Exploring Thermal Related Stuff in iDevices using Open-Source ToolExploring Thermal Related Stuff in iDevices using Open-Source Tool
Exploring Thermal Related Stuff in iDevices using Open-Source Tool
 
The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196
 
Manual orange
Manual orangeManual orange
Manual orange
 
iOS Automation Primitives
iOS Automation PrimitivesiOS Automation Primitives
iOS Automation Primitives
 
Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
 
Cc code cards
Cc code cardsCc code cards
Cc code cards
 
The Ring programming language version 1.5.3 book - Part 27 of 184
The Ring programming language version 1.5.3 book - Part 27 of 184The Ring programming language version 1.5.3 book - Part 27 of 184
The Ring programming language version 1.5.3 book - Part 27 of 184
 
Eclipse Summit Europe '10 - Test UI Aspects of Plug-ins
Eclipse Summit Europe '10 - Test UI Aspects of Plug-insEclipse Summit Europe '10 - Test UI Aspects of Plug-ins
Eclipse Summit Europe '10 - Test UI Aspects of Plug-ins
 
Iron python
Iron pythonIron python
Iron python
 
pcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFun
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
 
00_Introduction to Java.ppt
00_Introduction to Java.ppt00_Introduction to Java.ppt
00_Introduction to Java.ppt
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mind
 

More from Stephen Chin

DevOps Tools for Java Developers v2
DevOps Tools for Java Developers v2DevOps Tools for Java Developers v2
DevOps Tools for Java Developers v2Stephen Chin
 
10 Ways Everyone Can Support the Java Community
10 Ways Everyone Can Support the Java Community10 Ways Everyone Can Support the Java Community
10 Ways Everyone Can Support the Java CommunityStephen Chin
 
Java Clients and JavaFX: The Definitive Guide
Java Clients and JavaFX: The Definitive GuideJava Clients and JavaFX: The Definitive Guide
Java Clients and JavaFX: The Definitive GuideStephen Chin
 
DevOps Tools for Java Developers
DevOps Tools for Java DevelopersDevOps Tools for Java Developers
DevOps Tools for Java DevelopersStephen Chin
 
Java Clients and JavaFX - Presented to LJC
Java Clients and JavaFX - Presented to LJCJava Clients and JavaFX - Presented to LJC
Java Clients and JavaFX - Presented to LJCStephen Chin
 
JavaFX on Mobile (by Johan Vos)
JavaFX on Mobile (by Johan Vos)JavaFX on Mobile (by Johan Vos)
JavaFX on Mobile (by Johan Vos)Stephen Chin
 
Confessions of a Former Agile Methodologist (JFrog Edition)
Confessions of a Former Agile Methodologist (JFrog Edition)Confessions of a Former Agile Methodologist (JFrog Edition)
Confessions of a Former Agile Methodologist (JFrog Edition)Stephen Chin
 
Confessions of a Former Agile Methodologist
Confessions of a Former Agile MethodologistConfessions of a Former Agile Methodologist
Confessions of a Former Agile MethodologistStephen Chin
 
Zombie Time - JSR 310 for the Undead
Zombie Time - JSR 310 for the UndeadZombie Time - JSR 310 for the Undead
Zombie Time - JSR 310 for the UndeadStephen Chin
 
OpenJFX on Android and Devices
OpenJFX on Android and DevicesOpenJFX on Android and Devices
OpenJFX on Android and DevicesStephen Chin
 
Java 8 for Tablets, Pis, and Legos
Java 8 for Tablets, Pis, and LegosJava 8 for Tablets, Pis, and Legos
Java 8 for Tablets, Pis, and LegosStephen Chin
 
Devoxx4Kids NAO Workshop
Devoxx4Kids NAO WorkshopDevoxx4Kids NAO Workshop
Devoxx4Kids NAO WorkshopStephen Chin
 
Raspberry Pi Gaming 4 Kids - Dutch Version
Raspberry Pi Gaming 4 Kids - Dutch VersionRaspberry Pi Gaming 4 Kids - Dutch Version
Raspberry Pi Gaming 4 Kids - Dutch VersionStephen Chin
 
Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Stephen Chin
 
Raspberry Pi à la GroovyFX
Raspberry Pi à la GroovyFXRaspberry Pi à la GroovyFX
Raspberry Pi à la GroovyFXStephen Chin
 
LUGOD Raspberry Pi Hacking
LUGOD Raspberry Pi HackingLUGOD Raspberry Pi Hacking
LUGOD Raspberry Pi HackingStephen Chin
 
Moving to the Client - JavaFX and HTML5
Moving to the Client - JavaFX and HTML5Moving to the Client - JavaFX and HTML5
Moving to the Client - JavaFX and HTML5Stephen Chin
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage
Hacking JavaFX with Groovy, Clojure, Scala, and VisageHacking JavaFX with Groovy, Clojure, Scala, and Visage
Hacking JavaFX with Groovy, Clojure, Scala, and VisageStephen Chin
 
JavaFX 2 - A Java Developer's Guide (San Antonio JUG Version)
JavaFX 2 - A Java Developer's Guide (San Antonio JUG Version)JavaFX 2 - A Java Developer's Guide (San Antonio JUG Version)
JavaFX 2 - A Java Developer's Guide (San Antonio JUG Version)Stephen Chin
 

More from Stephen Chin (20)

DevOps Tools for Java Developers v2
DevOps Tools for Java Developers v2DevOps Tools for Java Developers v2
DevOps Tools for Java Developers v2
 
10 Ways Everyone Can Support the Java Community
10 Ways Everyone Can Support the Java Community10 Ways Everyone Can Support the Java Community
10 Ways Everyone Can Support the Java Community
 
Java Clients and JavaFX: The Definitive Guide
Java Clients and JavaFX: The Definitive GuideJava Clients and JavaFX: The Definitive Guide
Java Clients and JavaFX: The Definitive Guide
 
DevOps Tools for Java Developers
DevOps Tools for Java DevelopersDevOps Tools for Java Developers
DevOps Tools for Java Developers
 
Java Clients and JavaFX - Presented to LJC
Java Clients and JavaFX - Presented to LJCJava Clients and JavaFX - Presented to LJC
Java Clients and JavaFX - Presented to LJC
 
JavaFX on Mobile (by Johan Vos)
JavaFX on Mobile (by Johan Vos)JavaFX on Mobile (by Johan Vos)
JavaFX on Mobile (by Johan Vos)
 
Confessions of a Former Agile Methodologist (JFrog Edition)
Confessions of a Former Agile Methodologist (JFrog Edition)Confessions of a Former Agile Methodologist (JFrog Edition)
Confessions of a Former Agile Methodologist (JFrog Edition)
 
Confessions of a Former Agile Methodologist
Confessions of a Former Agile MethodologistConfessions of a Former Agile Methodologist
Confessions of a Former Agile Methodologist
 
Zombie Time - JSR 310 for the Undead
Zombie Time - JSR 310 for the UndeadZombie Time - JSR 310 for the Undead
Zombie Time - JSR 310 for the Undead
 
OpenJFX on Android and Devices
OpenJFX on Android and DevicesOpenJFX on Android and Devices
OpenJFX on Android and Devices
 
Java 8 for Tablets, Pis, and Legos
Java 8 for Tablets, Pis, and LegosJava 8 for Tablets, Pis, and Legos
Java 8 for Tablets, Pis, and Legos
 
DukeScript
DukeScriptDukeScript
DukeScript
 
Devoxx4Kids NAO Workshop
Devoxx4Kids NAO WorkshopDevoxx4Kids NAO Workshop
Devoxx4Kids NAO Workshop
 
Raspberry Pi Gaming 4 Kids - Dutch Version
Raspberry Pi Gaming 4 Kids - Dutch VersionRaspberry Pi Gaming 4 Kids - Dutch Version
Raspberry Pi Gaming 4 Kids - Dutch Version
 
Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)
 
Raspberry Pi à la GroovyFX
Raspberry Pi à la GroovyFXRaspberry Pi à la GroovyFX
Raspberry Pi à la GroovyFX
 
LUGOD Raspberry Pi Hacking
LUGOD Raspberry Pi HackingLUGOD Raspberry Pi Hacking
LUGOD Raspberry Pi Hacking
 
Moving to the Client - JavaFX and HTML5
Moving to the Client - JavaFX and HTML5Moving to the Client - JavaFX and HTML5
Moving to the Client - JavaFX and HTML5
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage
Hacking JavaFX with Groovy, Clojure, Scala, and VisageHacking JavaFX with Groovy, Clojure, Scala, and Visage
Hacking JavaFX with Groovy, Clojure, Scala, and Visage
 
JavaFX 2 - A Java Developer's Guide (San Antonio JUG Version)
JavaFX 2 - A Java Developer's Guide (San Antonio JUG Version)JavaFX 2 - A Java Developer's Guide (San Antonio JUG Version)
JavaFX 2 - A Java Developer's Guide (San Antonio JUG Version)
 

Recently uploaded

Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Recently uploaded (20)

Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

Oracle IoT Kids Workshop

  • 1. Oracle IoT Kids Workshop Stephen Chin Java Technology Ambassador JavaOne Content Chair @steveonjava
  • 4. Java and 3G in a Tiny Package > Cinterion EHS5
  • 7. = Have Java With Your Dessert Raspberry Pi
  • 9. Pis are Affordable $35 1 Box of Diapers Bicycle (but just 1 wheel) A Cake
  • 10. Chalkboard Electronics Touchscreen  10" or 7" Form Factor  Connects via HDMI/USB  Tested with JavaFX 8  10% Exclusive Discount: G1F0U796Z083
  • 11. How to Setup Your Pi > Step 1: Install Linux > Step 2: Download/Copy Java 8 for ARM > Step 3: Deploy and Run JVM Language Apps http://steveonjava.com/ javafx-on-raspberry-pi-3-easy-steps/
  • 12. Electronic Safety! > Unplug from wall before wiring > Get rid of static by touching a metal surface > Don't touch exposed wires/metal > Never remove/insert SD Card while power is on 12
  • 13. What Comes in Your Lab Kit 1. Touch Screen 2. SD Card 3. Keyboard 4. Yellow Box:  Power Adapter  LVDS Cable/Board  Raspberry Pi Model B  Mini-USB Cable (power) Please Save All the Packaging for Later
  • 14. Hooking Up the Pi (Part A) 1. Insert the SD Card in to the Pi  Will appear upside down when looking at the top of your Pi 2. Insert the HDMI board into the Pi's HDMI jack 3. Connect the Pi power to the HDMI board  Use the Micro USB Cable (short one) 14 Important: Connect everything before plugging into the wall
  • 15. Hooking Up the Pi (Part B) 4. Slide the LCD cable into the back of the display  Side with gold connectors goes up  Be careful, the connector is fragile! 5. Hook up the USB keyboard 6. Connect the USB end to one of the Pi's USB host ports  This provides touch input 15 Verify connections and plug into power now
  • 16. Is it Working? > Should get a bunch of flashing LEDs to indicate booting  Boot takes approx 30 seconds > The LCD screen should light up  Might be dim if the light sensor is obstructed > And you will should see a Linux boot screen with lots of text
  • 17. Logging In At the login prompt type your username: > pi And enter the password: > raspberry
  • 18. Running the JavaFX Sample Application Change directory to the project folder > cd MaryHadALittleLambda Run the build script > ant
  • 19. 19
  • 20. Hacking the Code Run the nano text editor: > nano src/sample/MapObject.java Save your changes: > Control-O Enter Exit Nano: > Control-X Compile/Run: > ant
  • 21. Mary Had a Little Lambda Mary had a little lambda Whose fleece was white as snow And everywhere that Mary went Lambda was sure to go! https://github.com/steveonjava/MaryHadALittleLambda
  • 22. Generating Streams From a collection: > anyCollection.stream(); Known set of objects: > Stream.of("bananas", "oranges", "apples"); Numeric range: > IntStream.range(0, 50) Iteratively: > Stream.iterate(Color.RED, > c -> Color.hsb(c.getHue() + .1, c.getSaturation(), > c.getBrightness())); 22
  • 23. Let's Create Some Barn Animals! SpriteView tail = s.getAnimals().isEmpty() ? s : s.getAnimals().get(s.getAnimals().size() - 1); Stream.iterate(tail, SpriteView.Lamb::new) .skip(1).limit(7) .forEach(s.getAnimals()::add); 23
  • 24. 24
  • 25. Filtering Streams Predicate Expression > public interface Predicate<T> { > public boolean test(T t); > } Filter out minors > adults = attendees.filter(a -> a.getAge() >= 1.8) 25
  • 26. Rainbow-colored Lambs! s.getAnimals().stream() .filter(a -> a.getNumber() % 4 == 2) .forEach(a -> a.setColor(Color.YELLOW)); s.getAnimals().stream() .filter(a -> a.getNumber() % 4 == 3) .forEach(a -> a.setColor(Color.CYAN)); s.getAnimals().stream() .filter(a -> a.getNumber() % 4 == 0) .forEach(a -> a.setColor(Color.GREEN)); 26
  • 27. 27
  • 28. Filtering Collections Collection.removeIf > Removes all elements that match the predicate List.replaceAll > In-place filtering and replacement using an unary operator ObservableCollection.filtered > Returns a list filtered by a predicate this is also Observable 28
  • 29. Picky Eaters… Predicate<SpriteView> pure = a -> a.getColor() == null; mealsServed.set(mealsServed.get() + s.getAnimals().filtered(pure).size() ); s.getAnimals().removeIf(pure); 29
  • 30. 30
  • 31. Mapping Streams Applies a Map Function to each element: > Function<? super T, ? extends R> Result: List is the same size, but may be a different type. 31
  • 32. Single Map s.getAnimals().setAll(s.getAnimals() .stream() .map(sv -> new Eggs(sv.getFollowing()) .collect(Collectors.toList()) ); 32
  • 33. Or a Double Map! s.getAnimals().setAll(s.getAnimals() .stream() .map(SpriteView::getFollowing) .map(Eggs::new) .collect(Collectors.toList()) ); 33
  • 34. 34
  • 35. Flat Map Applies a One-to-Many Map Function to each element: > Function<? super T, ? extends Stream<? extends R>> And then flattens the result into a single stream. Result: The list may get longer and the type may be different. 35
  • 37. 37
  • 38. Reduce Reduces a list to a single element given: > Identity: T > Accumulator: BinaryOperator<T> Result: List of the same type, but only 1 element left. 38
  • 39. And the (formerly little) Fox ate them all! Double mealSize = shepherd.getAnimals() .stream() .map(SpriteView::getScaleX) .reduce(0.0, Double::sum); setScaleX(getScaleX() + mealSize * .2); setScaleY(getScaleY() + mealSize * .2); shepherd.getAnimals().clear(); 39
  • 40. 40
  • 41. Mary Had a Little Lambda Project > Open-source project to demonstrate lambda features > Visual representation of streams, filters, and maps 41 https://github.com/steveonjava/MaryHadALittleLambda
  • 42. Stuff to do… > Changes to MaryHadALittleLambda:  Change the number of sheep  Make the rainbow have different colors  Change the fox size to be fatter/skinnier  Add new graphics (additional image files under images/extra) 42 camel.png lion.png greendragon.png cow.png Brownbear.png
  • 43. Stephen Chin tweet: @steveonjava blog: http://steveonjava.com nighthacking.com Real Geeks Live Hacking NightHacking Tour Hacking Time!
  • 45. Wiring LEDs > Wire the elements in series:  Connect the long end of the LED to GPIO  Connect the short end of the LED to the resistor  Connect the resistor to Ground 45 To GPIO To Ground
  • 46. Using a Breadboard > Pins are connected horizontally in the center > The edges are connect vertically > No current passes the center line 46
  • 47. Pi Cobbler > Connects your Pi to the Breadboard > The white line is Pin 1 > Connect it in the center top of your Breadboard 47
  • 48. Pi4J > The samples are located in /opt/pi4j/examples > Compile the samples by typing "./build" > Instructions for running the samples are printed out at the end of the build > Pi4j needs root access to use GPIO (use "sudo") 48
  • 49. ControlGpioExample 49 > Demonstrates Controlling Pins:  pin.low()  pin.toggle()  pin.pulse(duration, blocking) > Try creating your own pattern! sudo java -classpath .:classes:/opt/pi4j/lib/'*' BlinkGpioExample
  • 50. Wiring Buttons > Connect a circuit across two legs > While the button is pressed…  The legs numbered 1 and 2 are connected  The legs numbered 3 and 4 are connected 50
  • 51. ListenGpioExample 51 > Demonstrates Listening to a pin:  addListener(pinListener) > Change the message/action when a button is pressed! sudo java -classpath .:classes:/opt/pi4j/lib/'*' ListenGpioExample
  • 52. BlinkGpioExample 52 > Use LEDs and Buttons together! sudo java -classpath .:classes:/opt/pi4j/lib/'*' BlinkGpioExample
  • 53. Stephen Chin tweet: @steveonjava blog: http://steveonjava.com nighthacking.com Real Geeks Live Hacking NightHacking Tour Hacking Time!
  • 54. LeJOS How it works on the EV3
  • 55. The Heart of the EV3 > TI Sitara AM1808  ARM9, 300Mhz > 64MB RAM / 16MB Flash > Analog to Digital Converter > 4 Motor Ports > 4 Sensor Ports > Bluetooth / USB > MicroSD
  • 58. Color and Light Sensor
  • 59. High frequency sound waves Measuring mode Vs Presence Mode Ultrasonic Sensor
  • 62. Getting Started with LeJOS > Micro SD Card (> 2GB) > Compatible WIFI adapter  NetGear WNA1100  EDIMAX EW-7811Un > Linux (or a Linux VM) > Details here: Creating Your SD Card http://sourceforge.net/p/lejos/wiki/Home/
  • 64. Bluetooth Pairing > Make sure your Lego is turned on > Open "Devices and Printers" from the Start menu > Click "Add a device" > Select the Lego brick > After pairing, right click on the new device and choose "Connect using" > "Access point"
  • 65. Eclipse Setup > Open Eclipse > Go to "Preferences" > Click on leJOS EV3 > Change the brick name to "10.0.1.1" 65
  • 66. Creating a New LeJOS Project > Go to "File" > "New" > "Project…" > Choose a LeJOS EV3 Project 66
  • 67. Create a Class File > Create a new class ("File" > "New" > "Class") > Give it a package (e.g. sample) > Give it a name (e.g. LCDTest) 67
  • 68. Simple LeJOS Application import lejos.nxt.Button; import lejos.nxt.LCD; public class EV3FirstProgram { public static void main(String[] args) { LCD.clear(); LCD.drawString("First EV3 Program", 0, 5); Button.waitForAnyPress(); LCD.clear(); LCD.refresh(); } }
  • 69. Stephen Chin tweet: @steveonjava blog: http://steveonjava.com nighthacking.com Real Geeks Live Hacking NightHacking Tour Hacking Time!
  • 70. Parts you will need Step 1 Assemble Brace
  • 71. Step 2 Completed Brace Assemble Brace
  • 72. Parts you will need Step 1 Build Base
  • 73. Step 2 Completed Base Build Base
  • 74. Motor parts Snap them on partially Assemble Motor
  • 75. Take motor and base And connect them like this Assemble Motor
  • 76. Foot parts Step 1 Add a Foot
  • 77. Step 2 Add the Foot to the Base Add a Foot
  • 78. Assembled Foot and Base Add a Foot
  • 79. Lock parts Partially insert the red attachers Add a Lock
  • 80. Attach the lock Push down the red attachers to secure Add a Lock
  • 81. Tower parts Step 1 – push the rod all the way through Construct the Tower
  • 82. Step 2 Attach the Tower to the Base Construct the Tower
  • 84. Fan Motor parts Step 1 Build the Fan Motor
  • 85. Completed Fan Motor Build the Fan Motor
  • 86. Light Sensor parts Step 1 Construct the Light Sensor
  • 88. Fan Blade parts Step 1 Assemble the Fan Blades
  • 89. Fan Blade, Light Sensor, and Fan Motor Completed Fan Assemble the Fan
  • 91. Wind Turbine Wiring > Port A – Medium Moto  Power Fan > Port B – Large Motor  Rotate Wind Turbine > Port 1 – Light Sensor  Track Ambient Light 91
  • 92. Gear Box parts Step 1 EC: Gear Box Construction
  • 93. Completed Fan with Gear Box EC: Gear Box Construction
  • 94. Making the Wind turbine turn public class WindTurbine { public static void main(String[] args) { EV3MediumRegulatedMotor fan = new EV3MediumRegulatedMotor(MotorPort.A); fan.setSpeed(1500); fan.setAcceleration(150); fan.backward(); Delay.msDelay(10000); } }
  • 95. Making the Tower spin public class WindTurbine { public static void main(String[] args) { EV3LargeRegulatedMotor base = new EV3LargeRegulatedMotor(MotorPort.B); base.setSpeed(80); base.rotateTo(-90); base.rotateTo(90); } }
  • 96. Checking the Ambient Light public class WindTurbine { public static void main(String[] args) { EV3ColorSensor light = new EV3ColorSensor(SensorPort.S1); float[] sample = new float[1]; SensorMode mode = light.getAmbientMode(); mode.fetchSample(sample, 0); LCD.drawString("Light = " + sample[0], 0, 4); Delay.msDelay(5000); } }
  • 97. Putting it all together… > Can you write a program that will: 1. Rotate the fan in a circle 2. Check the ambient light while rotating 3. Move back to the brightest angle 4. Spin the fan http://commons.wikimedia.org/wiki/Wind_generator#mediaviewer/File:Eolienne_et_centrale_thermique_Nuon_Sloterdijk.jpg
  • 98. Stephen Chin tweet: @steveonjava blog: http://steveonjava.com nighthacking.com Real Geeks Live Hacking NightHacking Tour
  • 99. Safe Harbor Statement The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.