SlideShare une entreprise Scribd logo
1  sur  74
JCrete Embedded Java 
Hacking 
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
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 
11
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) 
13 
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 
14 
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
18
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 Project 
> Open-source project to demonstrate lambda features 
> Visual representation of streams, filters, and maps 
20 
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) 
21 
camel.png lion.png greendragon.png cow.png Brownbear.png
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 
To GPIO To Ground 
23
Using a Breadboard 
> Pins are connected 
horizontally in the center 
> The edges are connect 
vertically 
> No current passes the 
center line 
24
Pi Cobbler 
> Connects your Pi to the 
Breadboard 
> The white line is Pin 1 
> Connect it in the center 
top of your Breadboard 
25
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") 
26
ControlGpioExample 
27 
> 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 
28
ListenGpioExample 
29 
> 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 
30 
> Use LEDs and Buttons together! 
sudo java -classpath .:classes:/opt/pi4j/lib/'*' BlinkGpioExample
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 
Ultrasonic Sensor 
Measuring mode Vs Presence Mode
Infrared Sensor
Remote Control
Getting Started with LeJOS 
Creating Your SD Card 
> Micro SD Card (> 2GB) 
> Compatible WIFI adapter 
 NetGear WNA1100 
 EDIMAX EW-7811Un 
> Linux (or a Linux VM) 
> Details here: 
http://sourceforge.net/p/lejos/wiki/Home/
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" 
41
Creating a New LeJOS Project 
> Go to "File" > "New" > "Project…" 
> Choose a LeJOS EV3 Project 
42
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) 
43
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(); 
} 
}
Assemble Brace 
Parts you will need Step 1
Assemble Brace 
Step 2 Completed Brace
Build Base 
Parts you will need Step 1
Build Base 
Step 2 Completed Base
Assemble Motor 
Motor parts Snap them on partially
Assemble Motor 
Take motor and base And connect them like this
Add a Foot 
Foot parts Step 1
Add a Foot 
Step 2 Add the Foot to the Base
Add a Foot 
Assembled Foot and Base
Add a Lock 
Lock parts Partially insert the red attachers
Add a Lock 
Attach the lock Push down the red attachers to secure
Construct the Tower 
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
Build the Fan Motor 
Fan Motor parts Step 1
Build the Fan Motor 
Completed Fan Motor
Construct the Light Sensor 
Light Sensor parts Step 1
Construct the Light Sensor 
Completed Light Sensor
Assemble the Fan Blades 
Fan Blade parts Step 1
Assemble the Fan 
Fan Blade, Light Sensor, and Fan Motor Completed Fan
Assembled Wind Turbine 
65
Wind Turbine Wiring 
> Port A – Medium Moto 
 Power Fan 
> Port B – Large Motor 
 Rotate Wind Turbine 
> Port 1 – Light Sensor 
 Track Ambient Light 
66
EC: Gear Box Construction 
Gear Box parts Step 1
EC: Gear Box Construction 
Completed Fan with Gear Box
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 Tour 
Real Geeks 
Live Hacking 
nighthacking.com
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.

Contenu connexe

Tendances

Game programming with Groovy
Game programming with GroovyGame programming with Groovy
Game programming with GroovyJames Williams
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesJussi Pohjolainen
 
Remote Notifications
Remote NotificationsRemote Notifications
Remote NotificationsJosef Cacek
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time OptimizationKan-Ru Chen
 
ECS architecture with Unity by example - Unite Europe 2016
ECS architecture with Unity by example - Unite Europe 2016ECS architecture with Unity by example - Unite Europe 2016
ECS architecture with Unity by example - Unite Europe 2016Simon Schmid
 
TestowanieIoT2016
TestowanieIoT2016TestowanieIoT2016
TestowanieIoT2016kraqa
 
Knock, knock, who is there? Doze.
Knock, knock, who is there? Doze.Knock, knock, who is there? Doze.
Knock, knock, who is there? Doze.Yonatan Levin
 
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
 
Steam backup-game-files
Steam backup-game-filesSteam backup-game-files
Steam backup-game-filesssuser1eca7d
 
Console design template
Console design templateConsole design template
Console design templateLewisB2013
 

Tendances (13)

Game programming with Groovy
Game programming with GroovyGame programming with Groovy
Game programming with Groovy
 
5.Playtime
5.Playtime5.Playtime
5.Playtime
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
 
Remote Notifications
Remote NotificationsRemote Notifications
Remote Notifications
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
 
ECS architecture with Unity by example - Unite Europe 2016
ECS architecture with Unity by example - Unite Europe 2016ECS architecture with Unity by example - Unite Europe 2016
ECS architecture with Unity by example - Unite Europe 2016
 
TestowanieIoT2016
TestowanieIoT2016TestowanieIoT2016
TestowanieIoT2016
 
Knock, knock, who is there? Doze.
Knock, knock, who is there? Doze.Knock, knock, who is there? Doze.
Knock, knock, who is there? Doze.
 
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
 
Tdd in unity
Tdd in unityTdd in unity
Tdd in unity
 
Steam backup-game-files
Steam backup-game-filesSteam backup-game-files
Steam backup-game-files
 
Console design template
Console design templateConsole design template
Console design template
 
Atari 2600 VCS Programming
Atari 2600 VCS ProgrammingAtari 2600 VCS Programming
Atari 2600 VCS Programming
 

En vedette

Confessions of a Former Agile Methodologist
Confessions of a Former Agile MethodologistConfessions of a Former Agile Methodologist
Confessions of a Former Agile MethodologistStephen Chin
 
JavaFX and Scala in the Cloud
JavaFX and Scala in the CloudJavaFX and Scala in the Cloud
JavaFX and Scala in the CloudStephen Chin
 
Raspberry Pi à la GroovyFX
Raspberry Pi à la GroovyFXRaspberry Pi à la GroovyFX
Raspberry Pi à la GroovyFXStephen Chin
 
Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Stephen 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
 
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
 
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
 
OpenJFX on Android and Devices
OpenJFX on Android and DevicesOpenJFX on Android and Devices
OpenJFX on Android and DevicesStephen 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
 
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
 

En vedette (13)

DukeScript
DukeScriptDukeScript
DukeScript
 
Confessions of a Former Agile Methodologist
Confessions of a Former Agile MethodologistConfessions of a Former Agile Methodologist
Confessions of a Former Agile Methodologist
 
JavaFX and Scala in the Cloud
JavaFX and Scala in the CloudJavaFX and Scala in the Cloud
JavaFX and Scala in the Cloud
 
Raspberry Pi à la GroovyFX
Raspberry Pi à la GroovyFXRaspberry Pi à la GroovyFX
Raspberry Pi à la GroovyFX
 
Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)
 
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
 
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
 
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
 
OpenJFX on Android and Devices
OpenJFX on Android and DevicesOpenJFX on Android and Devices
OpenJFX on Android and Devices
 
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)
 
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
 
Devoxx4Kids NAO Workshop
Devoxx4Kids NAO WorkshopDevoxx4Kids NAO Workshop
Devoxx4Kids NAO Workshop
 

Similaire à JCrete Embedded Java Workshop

[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...Hackito Ergo Sum
 
Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!Codemotion
 
Arduino: interruptor de encendido controlado por Internet
Arduino: interruptor de encendido controlado por InternetArduino: interruptor de encendido controlado por Internet
Arduino: interruptor de encendido controlado por InternetSANTIAGO PABLO ALBERTO
 
Getting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer KitSulamita Garcia
 
IoT: Internet of Things with Python
IoT: Internet of Things with PythonIoT: Internet of Things with Python
IoT: Internet of Things with PythonLelio Campanile
 
Eclipse Kura Shoot a-pi
Eclipse Kura Shoot a-piEclipse Kura Shoot a-pi
Eclipse Kura Shoot a-piEclipse Kura
 
BURO Arduino Workshop
BURO Arduino WorkshopBURO Arduino Workshop
BURO Arduino WorkshopOmer Kilic
 
Contiki Operating system tutorial
Contiki Operating system tutorialContiki Operating system tutorial
Contiki Operating system tutorialSalah Amean
 
Arduino: Starter kit for arduino(manual de usuario)
Arduino: Starter kit for arduino(manual de usuario)Arduino: Starter kit for arduino(manual de usuario)
Arduino: Starter kit for arduino(manual de usuario)SANTIAGO PABLO ALBERTO
 
Gas leakage detection system
Gas leakage detection systemGas leakage detection system
Gas leakage detection systemAashiq Ahamed N
 
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, NepalArduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepalbishal bhattarai
 
IoT Getting Started with Intel® IoT Devkit
IoT Getting Started with Intel® IoT DevkitIoT Getting Started with Intel® IoT Devkit
IoT Getting Started with Intel® IoT DevkitVasily Ryzhonkov
 

Similaire à JCrete Embedded Java Workshop (20)

Station 1 POD1
Station 1 POD1Station 1 POD1
Station 1 POD1
 
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
 
IoT on Raspberry Pi
IoT on Raspberry PiIoT on Raspberry Pi
IoT on Raspberry Pi
 
Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!
 
Arduino: interruptor de encendido controlado por Internet
Arduino: interruptor de encendido controlado por InternetArduino: interruptor de encendido controlado por Internet
Arduino: interruptor de encendido controlado por Internet
 
Getting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer Kit
 
How to Hack Edison
How to Hack EdisonHow to Hack Edison
How to Hack Edison
 
IoT: Internet of Things with Python
IoT: Internet of Things with PythonIoT: Internet of Things with Python
IoT: Internet of Things with Python
 
IoT Workshop in Macao
IoT Workshop in MacaoIoT Workshop in Macao
IoT Workshop in Macao
 
IoT Workshop in Macao
IoT Workshop in MacaoIoT Workshop in Macao
IoT Workshop in Macao
 
Eclipse Kura Shoot a-pi
Eclipse Kura Shoot a-piEclipse Kura Shoot a-pi
Eclipse Kura Shoot a-pi
 
Intel galileo
Intel galileoIntel galileo
Intel galileo
 
BURO Arduino Workshop
BURO Arduino WorkshopBURO Arduino Workshop
BURO Arduino Workshop
 
Introduction to Microcontrollers
Introduction to MicrocontrollersIntroduction to Microcontrollers
Introduction to Microcontrollers
 
Contiki Operating system tutorial
Contiki Operating system tutorialContiki Operating system tutorial
Contiki Operating system tutorial
 
Arduino: Starter kit for arduino(manual de usuario)
Arduino: Starter kit for arduino(manual de usuario)Arduino: Starter kit for arduino(manual de usuario)
Arduino: Starter kit for arduino(manual de usuario)
 
PIC Axe049(print34)
PIC Axe049(print34)PIC Axe049(print34)
PIC Axe049(print34)
 
Gas leakage detection system
Gas leakage detection systemGas leakage detection system
Gas leakage detection system
 
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, NepalArduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
 
IoT Getting Started with Intel® IoT Devkit
IoT Getting Started with Intel® IoT DevkitIoT Getting Started with Intel® IoT Devkit
IoT Getting Started with Intel® IoT Devkit
 

Plus de 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
 
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
 
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
 
JavaFX 2 Using the Spring Framework
JavaFX 2 Using the Spring FrameworkJavaFX 2 Using the Spring Framework
JavaFX 2 Using the Spring FrameworkStephen Chin
 

Plus de Stephen Chin (9)

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
 
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
 
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)
 
JavaFX 2 Using the Spring Framework
JavaFX 2 Using the Spring FrameworkJavaFX 2 Using the Spring Framework
JavaFX 2 Using the Spring Framework
 

Dernier

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 

Dernier (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 

JCrete Embedded Java Workshop

  • 1. JCrete Embedded Java Hacking 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. Chalkboard Electronics Touchscreen  10" or 7" Form Factor  Connects via HDMI/USB  Tested with JavaFX 8  10% Exclusive Discount: G1F0U796Z083
  • 10. 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/
  • 11. 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 11
  • 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
  • 13. 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) 13 Important: Connect everything before plugging into the wall
  • 14. 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 14 Verify connections and plug into power now
  • 15. 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
  • 16. Logging In At the login prompt type your username: > pi And enter the password: > raspberry
  • 17. Running the JavaFX Sample Application Change directory to the project folder > cd MaryHadALittleLambda Run the build script > ant
  • 18. 18
  • 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
  • 20. Mary Had a Little Lambda Project > Open-source project to demonstrate lambda features > Visual representation of streams, filters, and maps 20 https://github.com/steveonjava/MaryHadALittleLambda
  • 21. 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) 21 camel.png lion.png greendragon.png cow.png Brownbear.png
  • 23. 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 To GPIO To Ground 23
  • 24. Using a Breadboard > Pins are connected horizontally in the center > The edges are connect vertically > No current passes the center line 24
  • 25. Pi Cobbler > Connects your Pi to the Breadboard > The white line is Pin 1 > Connect it in the center top of your Breadboard 25
  • 26. 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") 26
  • 27. ControlGpioExample 27 > Demonstrates Controlling Pins:  pin.low()  pin.toggle()  pin.pulse(duration, blocking) > Try creating your own pattern! sudo java -classpath .:classes:/opt/pi4j/lib/'*' BlinkGpioExample
  • 28. 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 28
  • 29. ListenGpioExample 29 > Demonstrates Listening to a pin:  addListener(pinListener) > Change the message/action when a button is pressed! sudo java -classpath .:classes:/opt/pi4j/lib/'*' ListenGpioExample
  • 30. BlinkGpioExample 30 > Use LEDs and Buttons together! sudo java -classpath .:classes:/opt/pi4j/lib/'*' BlinkGpioExample
  • 31. LeJOS How it works on the EV3
  • 32. 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
  • 35. Color and Light Sensor
  • 36. High frequency sound waves Ultrasonic Sensor Measuring mode Vs Presence Mode
  • 39. Getting Started with LeJOS Creating Your SD Card > Micro SD Card (> 2GB) > Compatible WIFI adapter  NetGear WNA1100  EDIMAX EW-7811Un > Linux (or a Linux VM) > Details here: http://sourceforge.net/p/lejos/wiki/Home/
  • 40. 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"
  • 41. Eclipse Setup > Open Eclipse > Go to "Preferences" > Click on leJOS EV3 > Change the brick name to "10.0.1.1" 41
  • 42. Creating a New LeJOS Project > Go to "File" > "New" > "Project…" > Choose a LeJOS EV3 Project 42
  • 43. 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) 43
  • 44. 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(); } }
  • 45. Assemble Brace Parts you will need Step 1
  • 46. Assemble Brace Step 2 Completed Brace
  • 47. Build Base Parts you will need Step 1
  • 48. Build Base Step 2 Completed Base
  • 49. Assemble Motor Motor parts Snap them on partially
  • 50. Assemble Motor Take motor and base And connect them like this
  • 51. Add a Foot Foot parts Step 1
  • 52. Add a Foot Step 2 Add the Foot to the Base
  • 53. Add a Foot Assembled Foot and Base
  • 54. Add a Lock Lock parts Partially insert the red attachers
  • 55. Add a Lock Attach the lock Push down the red attachers to secure
  • 56. Construct the Tower Tower parts Step 1 – push the rod all the way through
  • 57. Construct the Tower Step 2 Attach the Tower to the Base
  • 58. Construct the Tower Completed Tower
  • 59. Build the Fan Motor Fan Motor parts Step 1
  • 60. Build the Fan Motor Completed Fan Motor
  • 61. Construct the Light Sensor Light Sensor parts Step 1
  • 62. Construct the Light Sensor Completed Light Sensor
  • 63. Assemble the Fan Blades Fan Blade parts Step 1
  • 64. Assemble the Fan Fan Blade, Light Sensor, and Fan Motor Completed Fan
  • 66. Wind Turbine Wiring > Port A – Medium Moto  Power Fan > Port B – Large Motor  Rotate Wind Turbine > Port 1 – Light Sensor  Track Ambient Light 66
  • 67. EC: Gear Box Construction Gear Box parts Step 1
  • 68. EC: Gear Box Construction Completed Fan with Gear Box
  • 69. 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); } }
  • 70. 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); } }
  • 71. 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); } }
  • 72. 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
  • 73. Stephen Chin tweet: @steveonjava blog: http://steveonjava.com NightHacking Tour Real Geeks Live Hacking nighthacking.com
  • 74. 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.