To make it easier to change keyboard layout on a raspberry pi I wrote a small shell script. Be warned, this is one of my first scripts. So it is not optimal, and no guarantees. Use at your own risk.
clear
echo "--------------------------------"
echo "Script to change keyboard layout"
echo "--------------------------------"
echo "Which layout should be used? tr=turkish, se=swedish, gb=english etc"
read layout
sudo sed -i 's|XKBLAYOUT=....|XKBLAYOUT="'$layout'"|g' /etc/default/keyboard
Save the code to a file change_keyboard.sh (or downoad from here). Then add execute permission on that file with the command chmod 755 change_keyboard.sh Then you can run the file with ./change_keyboard.sh
Look in this list to find the 2 character code for the country layout you want to use.
Raspberry Pi tip of the day: If you want to maximize your window, but do not have a mouse to click the icon, you can press alt+spacebar to open the menu in the windowbar. Similarly, press alt+[the letter that is underlined] to open one of the the menu’s in the menubar.
On that page go to Downloads, click on the link that says “Raspbian (Debian for RaspberryPi)” and choose “Save”. This will save the file “S4A15_RP.deb” to /home/pi/.
Now open a terminal window, by clicking on LXTerminal on the desktop. In this window you can type commands to make your computer do things. Now we want to tell it to install the file we just downloaded.
The location you are at when you open the terminal should be /home/pi/. You can check this by typing the command pwd and pressing enter. It will then show you in which directory you are working.
This should also be the place we saved the file. We can check this by typing ls and enter. It will then show you all files and directories inside the directory we are now. In this list there should be a file called “S4A15_RP.deb” or similar.
Now let’s install it. For this we will use the command dpkg. But to run this command the computer demands that we have the rights to install this. Therefore we need to add the command sudo to execute the command as a super user. So in the end, the command you need to type becomes: sudo dpkg -i S4A15_RP.deb . It is important to write it with capital letters where needed, because otherwise the computer does not know what file you are talking about.
The installation will take a little while, and the computer will show you what it is doing by writing all kinds of text. When it is done (you see pi@raspberrypi ~$ again) you can close the window.
Now if you open the start menu and go to Programming, there should be S4A in the list. Click on it to start Scratch for Arduino.
Of course we also need an Arduino to program on. This Arduino needs to be prepared for S4A by loading a specific ‘sketch’ (an Arduino code file) onto it. This file can also be found on www.s4a.cat under Downloads (heading ‘Firmware’).
If you have access to a computer with the Arduino software already installed, it is easiest to do it from there. Open and upload the file to your Arduino as a regular Arduino code.
Note that not all Arduino’s work well with Scratch for Arduino. Currently only the Arduino Diecimila, Duemilanove and Uno are tested.
When you start S4A you will see a drawing of an Arduino already loaded as a sprite.
It will automatically search for the Arduino. If this does not find it, right click on the sensor board (the list with all the blue values) and select “stop searching board”.
Right click it again and click “Select Serial/USB-port”. Then there should pop up a little menu where you can select the port of your connected Arduino.
On a Raspberry Pi where the operating system (e.g. Raspbian) is installed using the NOOBS setup, using the analog port for video can give some trouble. In this post I’ll tell you why, and how to fix it.
The Raspberry Pi has quite a few ways to connect it to a screen. The most common one is the HDMI port because screens these days are often equipped with a HDMI connection. As an alternative, a HDMI to VGA adapter can be used to connect a VGA (analog) cable to the HDMI port. The third option is useful for old tv’s that only have a RCA/composite video port (or scart port, using this composite to scart adapter set to input). For the more advanced users you can also connect to the Raspberry using a remote desktop approach, and use for example an Android phone as screen (and mouse!).
Unfortunately, when NOOBS was used to install the os, the RCA connector seems to not work. The reason for this is that NOOBS has added a setting to the config.txt file, forcing the Raspberry to output its video on the HDMI port. So the solution for making the RCA port work is to remove that setting. Of course, if you have a HDMI cable or adapter, you can use that to boot the Raspberry, open the file and change the setting (see below for instructions). Otherwise if all you have is an RCA cable, it is easier said than done. As far as I have found, the only option then is to put the SD card into a Linux machine, and change the file that way. As a last resort, you could also give the Raspberry internet, figure out its IP address, and log in to it remotely to change the file.
If you have a HDMI cable
This is the easiest way.
Connect the Raspberry via the HDMI port, and start it up.
Open a terminal window (“LXTerminal”).
Type: cd ../../boot to get to the /boot/ directory.
Type: sudo nano config.txt to open the config.txt file with ‘administrator’ rights. If you are asked for a password, write raspberry and press enter. (You will not see anything happening while typing in the password.)
Move down to the line where it says: # NOOBS Auto-generated Settings:
Put a # in front of hdmi_force_hotplug=1 to disable it.
Press Ctrl+x to close the file, and press Enter to save it with the same name.
Now you are done! You can open the file once more to see if the saving worked. (If it did not, you might have forgotten the sudo command.)
Now you can restart the Raspberry with the RCA cable connected instead of the HDMI cable.
If you have a Linux computer
Turn off the Raspberry. Make sure it is off by unplugging the power (usb) cable.
Take the SD card out, and put it in the SD card reader of your computer.
After a short moment you should see a file explorer window open, showing the contents of the contents of the card. If nothing happens, open a file explorer yourself, and locate the SD card with the name BOOT.
In this BOOT directory you should find a file called config.txt. Open it in a text editor.
Scroll down to find the line where it says: # NOOBS Auto-generated Settings:
Put a # in front of hdmi_force_hotplug=1 to disable it.
Save and close the file.
Put the SD card back in the Raspberry and start it up, with the RCA cable connected.
If you have an Android phone, internet cable, and access to your router (and feel a bit adventurous).
There are more ways to do this, feel free to find alternatives to what I write here.
Start up the Raspberry without it being connected to a screen.
Connect the Raspberry with an internet cable to your router.
On your Android phone, find and install the app Ping Tools
Make sure your phone is connected on the wifi of the router. And make sure the Raspberry had some time to start up (1-2 minutes)
Open the app, tap on the top blue bar that says Ping and select Subnet scanner in the dropdown menu.
Click on the settings button (right next to the scan button).
In the list of ports, add the number 22. This is the port that the Raspberry will have open.
Then tap the scan button. Now your phone will try to look for other devices on the same network. This will take a while. If you see a device that has port 22 open, then that is most likely the iIP address of your Raspberry.
Now you can remotely connect to the Raspberry using SSH (Secure Shell). For this you can either download Putty on a computer or use an Android SSH app.
You probably also need a keyboard that gives you more control, like the Hacker’s keyboard.
Fill in pi@192.168.1.1 where you replace the IP address with the address of your Raspberry.
Type in raspberry as password.
Now that we have a SSH connection to the Raspberry, we can do anything that you can do in a terminal window on the Raspberry.
Type: cd ../../boot to get to the /boot/ directory.
Type: sudo nano config.txt to open the config.txt file with ‘administrator’ rights. If you are asked for a password, write raspberry and press enter. (You will not see anything happening while typing in the password.)
Move down to the line where it says: # NOOBS Auto-generated Settings:
Put a # in front of hdmi_force_hotplug=1 to disable it.
Press Ctrl+x to close the file, and press Enter to save it with the same name.
Now you are done! You can open the file once more to see if the saving worked. (If it did not, you might have forgotten the sudo command.)
Now you can restart the Raspberry with the RCA cable connected instead of the HDMI cable.
If it still does not work
Please note that if the HDMI cable is plugged in, the Raspberry will automatically switch to that as output. So make sure the RCA cable is connected before the Raspberry starts, and no HDMI cable is connected. If it still not works, feel free to ask your questions in the comments!
Because I don’t have any usb keyboard at home, other than my big and bulky laptop stand, it is a bit of a challenge to type on a Raspberry Pi. I’ve even went as far as copying letters one by one with a mouse to type something.
But now that is solved thanks to this forum post where JeremyF and Paenny explain how to get an on-screen keyboard.
The summary:
type: sudo apt-get install matchbox-keyboard
type ‘y’ say yes to installing
create a new file on the Desktop called ‘keyboard.sh’:
#!/bin/bash
matchbox-keyboard
Then open a terminal and write:
cd Desktop
chmod +x keyboard.sh
Now you can double click that file and execute it to start a big on-screen keyboard 🙂
PS: If you start the keyboard from a terminal, and then use that keyboard to type ctrl-c in that terminal your Raspberry will go nuts.