-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUltrasonic_Get_Distance_Zoom_Picture.html
45 lines (42 loc) · 1.34 KB
/
Ultrasonic_Get_Distance_Zoom_Picture.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Ultrasonic Get Distance Zoom Picture</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://webduino.io/components/webduino-js/dist/webduino-all.min.js"></script>
<script src="https://blockly.webduino.io/webduino-blockly.js"></script>
<script src="https://blockly.webduino.io/lib/runtime.min.js"></script>
<style>
#image {
width: 150px;
height: 150px;
transition: .3s;
-webkit-transition: .3s;
-moz-transition: .3s;
transform-origin: 75px 75px;
-webkit-transform-origin: 75px 75px;
-moz-transform-origin: 75px 75px;
}
</style>
</head>
<body>
<img src="http://blockly.webduino.io/media/webduino-logo.jpg" id="image">
<script>
var ultrasonic;
var image = document.getElementById("image");
boardReady({device: 'kzpV'}, board => {
board.systemReset();
board.samplingInterval = 250;
ultrasonic = getUltrasonic(board, 11, 10);
ultrasonic.ping(cm => {
console.log(ultrasonic.distance);
var imageWidth = ultrasonic.distance;
var imageHeight = ultrasonic.distance;
image.style.width = imageWidth+"px";
image.style.height = imageHeight+"px";
}, 500);
});
</script>
</body>