Getting Started: Running Hello World
Instead of making you type in the programs, we are going to use a technology called QR codes.
QR codes are two dimensional versions of barcodes like are used in supermarkets at the checkout.
Like barcodes, the black and white colours represent "on" and "off" or "1" and "0". A barcode can encode a small set of numbers like a product ID.
QR codes can hold many more numbers and the numbers correspond to characters. You can put about 4,000 characters in a QR code.
We are going use QR codes as any easy way to load programs onto the phones.
1. Find the SL4A program (used to run our Python programs)
2. Start the SL4A program
Find the SL4A program, this should look like this:
Start the program by tapping it.
You should see a list of programs (scripts). For example:
3. Bring up the barcode reader
Press the Android phone Menu
button (shown in red below).
Press the Add
Choose Scan Barcode
This brings up the scanner. Line the red line up over the QR code.
Try it now
with this QR code. This is for a script called HelloWorld.py
4. Running the program.
Find the cyber-helloworld.py
in the list of scripts and tap the name. This will bring up a menu.
Start the script by choosing the Run (with Terminal) option (highlighted in red below) -- the wheel runs it without the Terminal and the pencil allows you to edit the script directly on the phone.
This will bring up a Terminal on the phone where you can see the result of running the program (use the volume controls on the left side of the phone to enlarge the size of the output).
You should see something like the following after the program runs, finishes (process terminates) and an exit dialog is displayed.
to close the program (the data won't be lost because it is being stored on the phone's SDCARD).
5. Changing the program
Let's change the program.
This is the program:
The first line is the name of the program cyber-myhello.py
and the remaining lines are the program.
displays everything between the quotes ('Hello') get displayed on the screen.
What you are going to do is change MY NAME to your name.
We are going to use a QR creator to do this.
Open a new Browser window and this address in a new window.
Click on contents and choose Text
Copy and paste the program code into the Text content
Change your program so you display your name.
Create a QR code by click on Generate->
Now try and run the program. Check it with a tutor
6. Next: Making your phone talk
Normally we talk to the our phone. The next activity is making your phone talk to you.