RobotHelloUser

Hack the robot welcome demo and make your own.

Hello User

This sketch is the first thing you see when starting the robot. It gives you a warm welcome, shows you some of its really amazing features, and lets you personalize some data.

Hardware Required

  • Arduino Robot

Instruction

  1. Upload the example, you can keep the USB plugged.

  2. After the starting screen, you'll see a sequence of slides, read through them to see how this example works.

  3. When it comes to the input step, a virtual keyboard will show up on the bottom half of the TFT.

  4. You can use the knob and buttons to select your input.

  5. Use the knob to select key

  6. Press the middle button to input the key selected

  7. Press left/right buttons to move the cursor around

  8. When you're done with an input, input "Enter" on the virtual keyboard

  9. If you want to erase a character, move the cursor to the desired position, and input an empty space to make it disappear.

  10. There's a secret hidden in this example, find it out!

Try it out

Fill in your and the robot's names while listening to music
Fill in your and the robot's names while listening to music

Code

1/* Hello User
2
3 Hello User! This sketch is the first thing you see
4
5 when starting this robot. It gives you a warm welcome,
6
7 showing you some of the really amazing abilities of
8
9 the robot, and make itself really personal to you.
10
11 Circuit:
12
13 * Arduino Robot
14
15 created 1 May 2013
16
17 by X. Yang
18
19 modified 12 May 2013
20
21 by D. Cuartielles
22
23 This example is in the public domain
24
25 */
26
27#include <ArduinoRobot.h> // include the robot library
28#include <Wire.h>
29
30// include the utility function for the sketch
31// see the details below
32#include <utility/RobotTextManager.h>
33
34char buffer[20];//for storing user name
35
36void setup() {
37
38 //necessary initialization sequence
39
40 Robot.begin();
41
42 Robot.beginTFT();
43
44 Robot.beginSD();
45
46 // show the logos from the SD card
47
48 Robot.displayLogos();
49
50 // clear the screen
51
52 Robot.clearScreen();
53
54 // From now on, display different slides of
55
56 // text/pictures in sequence. The so-called
57
58 // scripts are strings of text stored in the
59
60 // robot's memory
61
62 // these functions are explained below
63
64 //Script 6
65
66 textManager.writeScript(5, 4, 0);
67
68 textManager.writeScript(9, 10, 0);
69
70 Robot.waitContinue();
71
72 delay(500);
73
74 Robot.clearScreen();
75
76 //Script 7
77
78 textManager.writeScript(6, 4, 0);
79
80 textManager.writeScript(9, 10, 0);
81
82 Robot.waitContinue();
83
84 delay(500);
85
86 Robot.clearScreen();
87
88 //Script 8
89
90 // this function enables sound and images at once
91
92 textManager.showPicture("init2.bmp", 0, 0);
93
94 textManager.writeScript(7, 2, 0);
95
96 textManager.writeScript(9, 7, 0);
97
98 Robot.waitContinue();
99
100 delay(500);
101
102 Robot.clearScreen();
103
104 //Script 9
105
106 textManager.showPicture("init3.bmp", 0, 0);
107
108 textManager.writeScript(8, 2, 0);
109
110 textManager.writeScript(9, 7, 0);
111
112 Robot.waitContinue();
113
114 delay(500);
115
116 Robot.clearScreen();
117
118 //Script 11
119
120 textManager.writeScript(10, 4, 0);
121
122 textManager.writeScript(9, 10, 0);
123
124 Robot.waitContinue();
125
126 delay(500);
127
128 Robot.clearScreen();
129
130 //Input screen
131
132 textManager.writeScript(0, 1, 1);
133
134 textManager.input(3, 1, USERNAME);
135
136 textManager.writeScript(1, 5, 1);
137
138 textManager.input(7, 1, ROBOTNAME);
139
140 delay(1000);
141
142 Robot.clearScreen();
143
144 //last screen
145
146 textManager.showPicture("init4.bmp", 0, 0);
147
148 textManager.writeText(1, 2, "Hello");
149
150 Robot.userNameRead(buffer);
151
152 textManager.writeText(3, 2, buffer);
153
154 textManager.writeScript(4, 10, 0);
155
156 Robot.waitContinue(BUTTON_LEFT);
157
158 Robot.waitContinue(BUTTON_RIGHT);
159
160 textManager.showPicture("kt1.bmp", 0, 0);
161}
162
163void loop() {
164
165 // do nothing here
166}
167
168/**
169
170textManager mostly contains helper functions for
171
172R06_Wheel_Calibration and R01_Hello_User.
173
174The ones used in this example:
175
176 textManager.setMargin(margin_left, margin_top):
177
178 Configure the left and top margin for text
179
180 display. The margins will be used for
181
182 textManager.writeText().
183
184 Parameters:
185
186 margin_left, margin_top: the margin values
187
188 from the top and left side of the screen.
189
190 Returns:
191
192 none
193
194 textManager.writeScript(script_number,line,column):
195
196 Display a script of Hello User example.
197
198 Parameters:
199
200 script_number: an int value representing the
201
202 script to be displayed.
203
204 line, column: in which line,column is the script
205
206 displayed. Same as writeText().
207
208 Returns:
209
210 none
211
212 textManager.input(line,column,codename):
213
214 Print an input indicator(">") in the line and column,
215
216 display and receive input from a virtual keyboard,
217
218 and save the value into EEPROM represented by codename
219
220 Parameters:
221
222 line,column: int values represents where the input
223
224 starts. Same as wirteText().
225
226 codename: either USERNAME,ROBOTNAME,CITYNAME or
227
228 COUNTRYNAME. You can call Robot.userNameRead(),
229
230 robotNameRead(),cityNameRead() or countryNameRead()
231
232 to access the values later.
233
234 Returns:
235
236 none;
237
238 textManager.writeText(line,column,text):
239
240 Display text on the specific line and column.
241
242 It's different from Robot.text() as the later
243
244 uses pixels for positioning the text.
245
246 Parameters:
247
248 line:in which line is the text displayed. Each line
249
250 is 10px high.
251
252 column:in which column is the text displayed. Each
253
254 column is 8px wide.
255
256 text:a char array(string) of the text to be displayed.
257
258 Returns:
259
260 none
261
262 textManager.showPicture(filename, x, y):
263
264 It has the same functionality as Robot.drawPicture(),
265
266 while fixing the conflict between drawPicture() and
267
268 sound playing. Using Robot.drawPicture(), it'll have
269
270 glitches when playing sound at the same time. Using
271
272 showPicture(), it'll stop sound when displaying
273
274 picture, so preventing the problem.
275
276 Parameters:
277
278 filename:string, name of the bmp file in sd
279
280 x,y: int values, position of the picture
281
282 Returns:
283
284 none
285
286*/

Contribute to Arduino

Join the community and suggest improvements to this article via GitHub. Make sure to read out contribution policy before making your pull request.

Missing something?

Check out our store and get what you need to follow this tutorial.

Suggest Changes

The content on docs.arduino.cc is facilitated through a public GitHub repository. You can read more on how to contribute in the contribution policy.