Show last authors
1 (% style="text-align:center" %)
2 [[image:t-rex.gif||class="img-rounded"]]
3
4 (% class="box infomessage" %)
5 (((
6 Use the phone sensors to create a t-rex detector. Now you know if a dino or a person is creeping up. Follow these steps to create a first version. Remix it afterwards and create something personal.
7 )))
8
9 (% class="box" %)
10 (((
11 == What bricks do you need? ==
12
13 Create a new program and add the following object:
14
15 (% style="text-align:center" %)
16 [[image:object.png]]
17 )))
18
19 (% class="row" %)
20 (((
21 (% class="col-xs-12 col-sm-6" %)
22 (((
23 (% class="box" %)
24 (((
25 = Now add these scripts to the dot object: =
26
27 **~1. Step**
28
29 The **dot **which visualizes the vibration should start at the upper edge of your phone. Set the y-value to the maximum of your phone’s screen. In this example it is 960. Also set the size of the dot to a size you like.
30
31 (% style="text-align:center" %)
32 [[image:1.png]]
33 )))
34 )))
35
36 (% class="col-xs-12 col-sm-6" %)
37 (((
38 (% class="box" %)
39 (((
40 **2. Step**
41
42 Now add the** pen down-brick**. From now on the **dot **object is drawing a line.
43
44 (% style="text-align:center" %)
45 [[image:2.png]]
46 )))
47 )))
48 )))
49
50 (% class="row" %)
51 (((
52 (% class="col-xs-12 col-sm-6" %)
53 (((
54 (% class="box" %)
55 (((
56 **3. Step**
57
58 The **dot **is ready to move over the whole stage. To do this reduce the y-value by minus 1 for the whole screen height. The screen height can be easily computed by multiplying the maximum y-value with two.
59
60 (% style="text-align:center" %)
61 [[image:3.png]]
62 )))
63 )))
64
65 (% class="col-xs-12 col-sm-6" %)
66 (((
67 (% class="box" %)
68 (((
69 **4. Step**
70
71 You have to set the x-value of the **dot **according to the vibration. For this you can use a combination of the accelerations of the phone. Just add the accelerations of the x, y, and z direction and multiply the sum with the factor 100. You find the “acceleration_x”, “acceleration_y” and “acceleration_z” sensor value under the category device in the formula editor. Change the factor if you want the detector to react more or less sensitive.
72
73 (% style="text-align:center" %)
74 [[image:4.png]]
75 )))
76 )))
77 )))
78
79 (% class="box" %)
80 (((
81 == Remix Inspirations ==
82
83 [[Change how the t-rex detector looks like>>https://share.catrob.at/pocketcode/program/31926]]
84
85 [[Add functionality to the t-rex detector >>https://share.catrob.at/pocketcode/program/32735]]
86 )))
87
88 (% class="box infomessage" %)
89 (((
90 [[Download the program>>https://share.catrob.at/pocketcode/program/31927]]
91 )))