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

The clock and your location

Section 10: SensorsLesson 10.2 · ⏱ 9 min
The button finds the location by GPS, the clock updates every second, and shaking shows a message and plays a sound
The button finds the location by GPS, the clock updates every second, and shaking shows a message and plays a sound
The clock is running, and we shook the phone
The clock is running, and we shook the phone
  • 📍 find my location asks the phone where it is. It will ask you for permission first.
  • latitude and longitude are the two numbers of a place on the map.
  • 🕒 clock gives the hour, the minute, the second or the whole time.
📌 Note
Sensors work better on a real phone: open your app on it (lesson 12-1).

📌 Another example: a digital clock

Every second we write the hour, the minute and the second.

The design
The design
The blocks
The blocks
In the lab: the clock
In the lab: the clock
✍️ 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 only the second, and it changes every second.

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

Result: the second's number.

Medium

Good morning before 12 o'clock, and good evening after it.

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

Result: a greeting that fits the time.

Hard

A button that finds your location and writes the latitude.

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

Result: the latitude in numbers.

Finished the lesson? Mark it so your progress counts.