انتقل للمحتوى
Robo EgyptRobo Egypt
☰ Course contents

Tilting and shaking: the spirit level

Section 10: SensorsLesson 10.1 · ⏱ 10 min
Every 0.05 seconds the ball moves with the phone's tilt, and shaking takes it back to the middle
Every 0.05 seconds the ball moves with the phone's tilt, and shaking takes it back to the middle
We tilted the phone to the right (the ➡️ arrow on the computer)
We tilted the phone to the right (the ➡️ arrow on the computer)
  • tilt left-right is the phone tilting right and left, and forward-back forward and back.
  • On the computer the arrow makes the tilt 30. On a real phone the tilt changes as you tilt it.
  • when the phone is shaken: on the computer press the letter S.
🖥️ What happens on the stage?
In the lab “Tilt: 30 , 0” appeared and the ball moved right, then we pressed S and it went back to the middle.

📌 Another example: the tilt arrow

It shows an arrow in the direction the phone is tilted.

The design
The design
The blocks
The blocks
In the lab: tilted to the right
In the lab: tilted to the right
✍️ Practise
Make the example yourself: put the parts in “🎨 Design”, then the blocks, and tap ▶ Run.
✍️ Practise here in the lessonor open the lab in a new page ↗

🎯 Challenge yourself

Easy

Write the right-left tilt number.

👀 Show the solution
The design
The design
The blocks
The blocks
In the lab
In the lab

Result: it writes 30 when tilted.

Medium

Shaking the phone rolls a dice.

👀 Show the solution
The design
The design
The blocks
The blocks
In the lab
In the lab

Result: a number from 1 to 6.

Hard

The screen is green if the phone is level, and red if it is tilted.

👀 Show the solution
The design
The design
The blocks
The blocks
In the lab
In the lab

Result: tilted, then level.

Finished the lesson? Mark it so your progress counts.