how does "when screen1. otherscreenclose" work? and help refine my app

85 views
Skip to first unread message

Kai Sze

unread,
Jun 15, 2018, 6:03:59 AM6/15/18
to mitappinv...@googlegroups.com

I am trying to make an alarm clock like thing with Mit App Inventor 2 and Arduino Uno. So with that in mind, i created a button to bring out a new screen to choose a few days of a week. This is because i want it to be able to select a few days and not daily or once a week. On the new screen, i have put checkbox for monday to sunday and a checkbox for daily. After i checked checkbox for daily, i will click a button to close screen. Then, i will get back to screen1 and one of the invisible textbox will have its text changed. Then, i will pick a with time picker and after time is selected, it will change another invisible textbox's text. An on or off button will only appear if both of the textbox has the same text. But the problem is the textbox that supposed to change its text when the day is picked and the screen2 will reinitialise and the checkbox will all became unchecked. Also i would gladly accept suggestion to refine my project.

Thank you for time and attention.

Ghica

unread,
Jun 15, 2018, 7:20:03 AM6/15/18
to MIT App Inventor Forum
Some remarks:
  1. Having a second screen is usually not a good idea if you can avoid it. In this case you may loose your BT connection when going from screen 1 to screen2 and back.
  2. Rename your components! Do you know in about a week from now what TextBox13 was for? Even if you do, you make it hard for us to understand.
  3. You cannot receive data from your Arduino immediately after you have sent it. Enable a clock in your Button5.Click, and check in the Clock.Timer event what you received. Disable the clack when you received what you expect. 
  4. What id the function of the Arduino, to wake you up with some lights?
  5. This is the showstopper: it seems to me that your app needs to be active in the background. At this moment that is NOT possible with App Inventor.
Cheers, Ghica.

Kai Sze

unread,
Jun 15, 2018, 7:40:24 AM6/15/18
to MIT App Inventor Forum
1. Is there another way to select multiple days with Mit App Inventor?
2. Hope this helps you understand my blocks better
3. I will try this later
4. To set up alarms with TimeAlarms library
5. Hopefully after you understand my project better, you can help me come out with a solution

Thank you very much for your time and attention

Kai Sze

unread,
Jun 15, 2018, 8:56:03 AM6/15/18
to mitappinv...@googlegroups.com
What is a naming compartment?
I wan to make alarms like below, after i set the day and time, the app will send message to my arduino and my arduino will use the message to setup up alarms using TimeAlarms library. With the alarms, my arduino will light up leds and make the buzzer ring. I put blocks to receive message from arduino becoz the arduino need to diffrenciate day, hour and minute. So after app have sent the days, my arduino set up day and return a message and the app will continue its job to send the hour and so on.

Thank you very much for your time and attention

Ghica

unread,
Jun 15, 2018, 12:00:07 PM6/15/18
to MIT App Inventor Forum
Here is a way how you can do it. I made a very incomplete example, just to show you some concepts about list handling and any-blocks. 
I do not want to spoil your fun of finding out. To start, look in the FAQ under lists: https://groups.google.com/forum/#!msg/mitappinventortest/wqJin0qO8M0/8xUafdROAgAJ


Cheers, Ghica
ArduinoClock.aia

Kai Sze

unread,
Jun 16, 2018, 3:32:46 AM6/16/18
to MIT App Inventor Forum
That helps a lot! Thank you! But what if I want to have two alarm for a day? Is there another way to do it aside from creating another row of timepicker?

Ghica

unread,
Jun 16, 2018, 4:12:20 AM6/16/18
to MIT App Inventor Forum
Hi Kai,
You could have a list of times, and when you press on the listpicker it adds to the list. You would have to bother about being able to remove it again etc., so the interface is not really simple.

If I were you, make it work with just one time, then come back here and try to expand your example.
It is always a good idea to develop your app in steps, I cannot say that enough.
Cheers, Ghica.

Kai Sze

unread,
Jun 17, 2018, 10:22:55 AM6/17/18
to MIT App Inventor Forum
In your first reply, you mentioned "You cannot receive data from your Arduino immediately after you have sent it. Enable a clock in your Button5.Click, and check in the Clock.Timer event what you received. Disable the clack when you received what you expect" How to make this work?

Ghica

unread,
Jun 17, 2018, 5:17:11 PM6/17/18
to MIT App Inventor Forum
Look for example in this thread: https://groups.google.com/forum/#!msg/mitappinventortest/lVaCyAeWm_4/ADjvy05wAwAJ
But there are many examples in this forum.
Cheers, Ghica.

Kai Sze

unread,
Jun 18, 2018, 11:47:09 AM6/18/18
to MIT App Inventor Forum
Please help me... I have to be honest that I don't know how to continue and what to fix. I don't know how to code my arduino also. I will just try to explain what i want and i hope you could help me with it. So when he btnOpenalarm1 is clicked, App Inventor will send a text to my arduino telling it to set up the alarm for slot one. This because my project have different slot haven each slot have different function when the alarm goes off. So after the arduino knows which slot to set alarm on with the upcoming data, it will return a text telling App Inventor to continue its job. With that, App Inventor will check my checkbox and if all the days have been selected then it will send a "0" to the arduino and if not, it will check Monday, Tuesday, Wednesday and so on and send respective number which is 1 for Monday, 2 for Tuesday, 3 for Wednesday...all the way to 7 for Sunday. After the arduino receive the numbers, it will send back "1" to let App Inventor continue its job and the App Inventor will send timepicker.hour. The arduino will send "2" after it receivesthe timepicker.hour and the App Inventor will send timepicker.minute next. The hours and minutes sent by the App Inventor is the timepicker that have their checkbox checked. I felt so lost even after browsing all the examples from the link you gave me.

Thank you for your time and attention

ArduinoClock (1).aia
Reply all
Reply to author
Forward
0 new messages