raspberry pi with java (jjug)

Post on 17-Jul-2015

1.753 Views

Category:

Technology

6 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Java with Raspberry Pi

Stephen Chin (@steveonjava)Java Community ManagerJavaOne Conference Chair

Java ScaleRaspberry Pi Coffee

Fuglen Coffee

3

The Coffeeshop Roast Works

4

About Life Coffee

5

Bridge Coffee and Ice Cream

6

Bridge Coffee and Ice Cream

7

Latte at Bridge

8

Peace Coffee Roasters

9

Aeropress at Peace

10

Little Nap Coffee Stand

11

Espresso from Little Nap

12

AeroPress

13

Porlex Grinder

14

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

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

17

Driving Test

https://www.flickr.com/photos/davidyuweb/1352312273

18

19

20

21

22

23

Up-Up-Down-Down-Left-Right-Left-Right B, A, Start

24

Meet Mr. Grabby

25

https://www.flickr.com/photos/pasukaru76/8278458818/https://www.flickr.com/photos/fallentomato/5656700432/

+ =

Meet Mr. Grabby

26

Mr. Grabby's Back

27

Controller

Grabber

Controller

• Raspberry Pi

• Cooking Hacks Shield

• MakeBlocks ME Base Shield

28

Mr. Grabby's Belly

29

Line Follower

Batteries

DC Motors

How Line Followers Work

30

• Infrared LED

– Bounced light off the ground

• Infrared Luminosity Sensor

– Detects reflected light

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

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

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

Ultimaker 2

34

35

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

37

38

JJUG Exclusive Pepper Workshop

39

Stephen Chintweet: @steveonjavablog: 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.

41

top related