Me:
I need MIT App Inventor code for a simple alarm clock
You.com/chat
Sure! Here's an example of MIT App Inventor code for a simple alarm clock:
- First, drag and drop the following components from the Palette to the Viewer:
- 1 Clock component
- 1 Button component
- 1 TimePicker component
- 1 Sound component
- Rename the components as follows:
- Clock:
Clock1
- Button:
Button1
- TimePicker:
TimePicker1
- Sound:
Sound1
- Set the properties of the components:
- Button1: Set the
Text
property to "Set Alarm" - TimePicker1: Set the
Visible
property toFalse
- Add the following blocks to the Screen's blocks area:
When Button1.Click
Set TimePicker1.Visible to True
When TimePicker1.AfterTimeSet
Set TimePicker1.Visible to False
Set Clock1.TimerEnabled to True
When Clock1.Timer
If Clock1.Hour = TimePicker1.Hour and Clock1.Minute = TimePicker1.Minute then
Call Sound1.Play
Set Clock1.TimerEnabled to False
End If
Make sure to add the necessary permissions in the App Inventor Designer view to access the device's clock and sound features.
This code sets up a simple alarm clock functionality. When you click the "Set Alarm" button, the time picker will appear. After you set the desired alarm time, the clock's timer will start running. Once the current time matches the alarm time, the sound component will play and the timer will be disabled.
Feel free to customize the code and add more features according to your requirements.
I just found this interesting.