raspberry pi with java (jjug)
TRANSCRIPT
![Page 1: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/1.jpg)
Java with Raspberry Pi
Stephen Chin (@steveonjava)Java Community ManagerJavaOne Conference Chair
![Page 2: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/2.jpg)
Java ScaleRaspberry Pi Coffee
![Page 3: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/3.jpg)
Fuglen Coffee
3
![Page 4: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/4.jpg)
The Coffeeshop Roast Works
4
![Page 5: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/5.jpg)
About Life Coffee
5
![Page 6: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/6.jpg)
Bridge Coffee and Ice Cream
6
![Page 7: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/7.jpg)
Bridge Coffee and Ice Cream
7
![Page 8: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/8.jpg)
Latte at Bridge
8
![Page 9: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/9.jpg)
Peace Coffee Roasters
9
![Page 10: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/10.jpg)
Aeropress at Peace
10
![Page 11: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/11.jpg)
Little Nap Coffee Stand
11
![Page 12: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/12.jpg)
Espresso from Little Nap
12
![Page 13: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/13.jpg)
AeroPress
13
![Page 14: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/14.jpg)
Porlex Grinder
14
![Page 15: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/15.jpg)
Finding a USB Scalepublic static UsbScaleTest findScale() throws UsbException {
UsbServices services = UsbHostManager.getUsbServices();
UsbHub rootHub = services.getRootUsbHub();
// Dymo M10 Scale:
UsbDevice device = findDevice(rootHub, (short) 0x0922, (short) 0x8003);
// Dymo M25 Scale:
if (device == null) {
device = findDevice(rootHub, (short) 0x0922, (short) 0x8004);
}
return new UsbScaleTest(device);
}
15
![Page 16: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/16.jpg)
Printing out Weightpublic void dataEventOccurred(UsbPipeDataEvent upde) {
boolean empty = data[1] == 2;
boolean overweight = data[1] == 6;
boolean negative = data[1] == 5;
boolean grams = data[2] == 2;
int scalingFactor = data[3];
int weight = (data[4] & 0xFF) + (data[5] << 8);
System.out.println(String.format("Weight = %,.1f%s",
scaleWeight(weight, scalingFactor),
grams ? "g" : "oz"));
}
16
![Page 17: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/17.jpg)
17
Driving Test
https://www.flickr.com/photos/davidyuweb/1352312273
![Page 18: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/18.jpg)
18
![Page 19: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/19.jpg)
19
![Page 20: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/20.jpg)
20
![Page 21: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/21.jpg)
21
![Page 22: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/22.jpg)
22
![Page 23: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/23.jpg)
23
![Page 24: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/24.jpg)
Up-Up-Down-Down-Left-Right-Left-Right B, A, Start
24
![Page 25: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/25.jpg)
Meet Mr. Grabby
25
https://www.flickr.com/photos/pasukaru76/8278458818/https://www.flickr.com/photos/fallentomato/5656700432/
+ =
![Page 26: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/26.jpg)
Meet Mr. Grabby
26
![Page 27: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/27.jpg)
Mr. Grabby's Back
27
Controller
Grabber
![Page 28: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/28.jpg)
Controller
• Raspberry Pi
• Cooking Hacks Shield
• MakeBlocks ME Base Shield
28
![Page 29: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/29.jpg)
Mr. Grabby's Belly
29
Line Follower
Batteries
DC Motors
![Page 30: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/30.jpg)
How Line Followers Work
30
• Infrared LED
– Bounced light off the ground
• Infrared Luminosity Sensor
– Detects reflected light
![Page 31: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/31.jpg)
Getting GPIO
gpio = GpioFactory.getInstance();
lineFollowA = gpio.provisionDigitalInputPin(RaspiPin.GPIO_13, "LineFollowA");
lineFollowB = gpio.provisionDigitalInputPin(RaspiPin.GPIO_14, "LineFollowA");
startGPIO();
boolean leftSensor = lineFollowA.getState().isHigh();
boolean rightSensor = lineFollowB.getState().isHigh();
31
![Page 32: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/32.jpg)
Line Following Algorithm
if (leftSensor && rightSensor) { //we are lost
doDrive(lineLocation);
} else if (!leftSensor && !rightSensor) { //on the line
lineLocation = Drive.forward; doDrive(Drive.forward);
} else if (!leftSensor && rightSensor) { //off the right
lineLocation = Drive.left; doDrive(Drive.forward);
} else if (leftSensor && !rightSensor) { //off the left
lineLocation = Drive.right; doDrive(Drive.forward);
}
32
![Page 33: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/33.jpg)
Make your own Mr. Grabby
• MakeBlock Advanced Robotics Kit
• MakeBlock ME Base Shield
• Cooking Hacks Shield
• USB Battery (1A)
• Code here:
https://github.com/steveonjava/LineFollower
33
![Page 34: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/34.jpg)
Ultimaker 2
34
![Page 35: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/35.jpg)
35
![Page 36: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/36.jpg)
Java Constructive Geometry (JCSG / JFXScad)
• Create geometries from pure Java code
• Visualize with a JavaFX user interface
• Generate STL files for 3D printing
• Project sites:
https://github.com/miho/JCSG
https://github.com/miho/JFXScad
36
![Page 37: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/37.jpg)
37
![Page 38: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/38.jpg)
38
![Page 39: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/39.jpg)
JJUG Exclusive Pepper Workshop
39
![Page 40: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/40.jpg)
Stephen Chintweet: @steveonjavablog: http://steveonjava.com
nighthacking.com
Real Geeks
Live Hacking
NightHacking Tour
![Page 41: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/41.jpg)
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.
41
![Page 42: Raspberry Pi with Java (JJUG)](https://reader030.vdocuments.us/reader030/viewer/2022020218/55a92a001a28abae768b4882/html5/thumbnails/42.jpg)