2017 MIT App Inventor Master Training was held in Guangzhou from July 7 to July 9. The workshop was sponsored by Google China and hosted by GEIC (Guangzhoug Education Information Center), SCUT (South China University of Technology). The workshop was organized by Liyue, the professor of SCUT. The most exciting thing is that Professor Harold Abelson attended our last day activity!
Hal visited GNIC and we gave him a mini party to celebrate his birthday. Several group teachers showed their works to Hal.
The main topic of the workshop is App Inventor and Robot. The robots are produced by Gao Weiguang (the IT teacher of Guangzhuo Baiyun Middle School) and his students. The shell of robots are printed by 3D printer.
Here are some fragments of teachers' works:
The splash screen use Canvas component, the robot is an imagesprite component. When you touch the robot, it will open the bluetooth AddressesAndNames list and you may choose the robot's bluetooth name to connect. Once the phone connects the robot successfully, a new screen will show.
You may click buttons to let the robot twinkle his eyes, dance, sing a happy birtyday song or speak out the temperature, humidity and distance, etc. You can ask some questions to the robot and he can reply to you, too. Cool, isn't it?
Again, 26th July, Happy 70th Birthday to professor Harold Abelson!
This works gained first prize in 2016 Guangdong Student Maker Contest!
Arthor: Huanglan, Liu jianke. They are all grade 9 students.
Mentors: He wei, Xiangqun Chen
User Interface - Components
- Image 1: to show logo
- lblSpace1~lblSpace6: to add spaces between components
- listConnect: Listpicker component to a bluetooth address to connect
- VerticalControl: VerticalArrangement component to put LED control panel. It includes several horizontal arrangements.
- bthDisconnect: To disconnect the phone and LED Strips
- lblNotifier: To show notifier
- BluetoothClient1: BluetoothClient Component to connent the phone and LED strips
- Clock1: in each interval time to check if there is a text to send to arduino board.
- btnOn: Button component to turn the LED on or off
- HorizontalTemp: To show color temperature
SliderTemp: Slider component to change color temerature
- HorizontalBrightness: To show color brightness
SliderBrightness: Slider component to change color brightnes
TimePicker1: TimePicker component to pick time
SpinnerChoose: To select an event to do
btnStart: Button component to start a timer
btnCancell: Button component to cancell a timer
- Initialize variables
hour: hour of timer
minute: minute of timer
doWhat: text that sends to arduino board
status: 1: the light is on, 0: the light is off
ifSent: 1: the text has been sent, 0: the text hasn't been sent
- Initialize screen: to initialize the background color of buttons
- Before connecting, set listConnect.Elements to BluetoothClient1.AddressAndNames
- After picking, if the cell phone is connected with arduino board, make the control panel to show, and hide listConnect.
- When adjust temperature slider, gets the value of thumbPosition and calls BluetoothClient.SendText to send corresponding text. You should first round thumPosition.
If thumPosition is
1, then send text "A": The light is cold.
2, then send text "B": The light is warm.
3, then send text "C": The light is cold-warm.
- When adjust brightness slider, gets the value of thumbPosition and calls BluetoothClient.SendText to send corresponding text. You should first round thumPosition.
If thumbPosition is
1, then send text "a", the brightness is 10% of
2, then send text "b"
3, then send text "c"
4, then send text "d"
5, then send text "e"
6, then send text "f"
7, then send text "g"
8, then send text "h"
9, then send text "i"
10, then send text "j"
- When after choosing an event to do in time, to set value to doWhat variable.
Light on, then set the variable doWhat to "A".
Light off, then set the variable doWhat to "B"
Warm light, then set the variable doWhat to "C"
Cold light, then set the variable doWhat to "D"
Cold_Warm light, then set the variable doWhat to "E"
10% brightness, then set the variable doWhat to "a"
20% brightness, then set the variable doWhat to "b"
30% brightness, then set the variable doWhat to "c"
40% brightness, then set the variable doWhat to "d"
50% brightness, then set the variable doWhat to "e"
60% brightness, then set the variable doWhat to "f"
70% brightness, then set the variable doWhat to "g"
80% brightness, then set the variable doWhat to "h"
90% brightness, then set the variable doWhat to "i"
100% brightness, then set the variable doWhat to "j"
- When after picking time, set global.minute to TimePicker1.Minute, set global.hour to TimePicker1.Hour
- When btnStart.Click, if time is valid, then set gloabal ifSent to 0, make btnStart and TimePicker1 disable, make btnCancell and Clock1 enable.
- When btnCancell.Click, then set ifSent to 0, set Clock1.TimeEnabled to false.
- When Clock1.Timer, if current time hits the setting time, the sends variable doWhat to arduino board, sets variable ifSent to 1, sets btnStart.Enabled and TimePicker1.Enabled to true, sets btnCancelled.Enable and Clock1.TimeEnabled to false.
When btnDisconnect.Click, set VerticalControl.Visible adn btnDisconnect.Visible to false, set listConnect.Visible to true, call BluetoothClient1.Disconnect.
Now we have finished all blocks. But there are so many if-then-else blocks and they do similar things!
we may optimize our blocks.
- First, we add two variables:
sendText: to store all texts that send to arduino board: A~E, a~j
- Define some procedures to call:
procedure setSendTextList: to set sendText to a list that has 15 items.
- Initialize screen:
- When SpinnerChoose.AfterSelecting:
- When btnOn.Click:
- When SliderBrightness.PositionChanged:
- When SliderTemp.PositionChanged:
So you see, the blocks are much more simple and logical.
当改变色温时，发送相应文本： C为白光，D为黄白光，E 为黄光
当选择完需要定时的任务后，发送相应字符： 15个任务对应15个字符，分别为A~E, a~j