The examples given here are for modifying the wlan0 interface. Replace wlan0 with the interface you are configuring. i.e. (eth0,wlan1)
Method 1
This was the typical way to add a static IP address to a Pi, if you have issues with this, then try Method 2.
sudo vi /etc/network/interfaces
In the file it is pretty easy to see which lines control which interface, find the lines that control wlan0 (or the interface your configuring) and change/add to look like below.
iface wlan0 inet static
address 192.168.42.109
netmask 255.255.255.0
gateway 192.168.42.1
Save the file, reboot, and the Pi should come up with the new static IP.
Method 2
It looks like on the newer versions of Raspbian, the above method does not work anymore, so now you have to edit the following file
sudo vi /etc/dhcpcd.conf
and add the following lines.
interface wlan0
static ip_address=192.168.42.109/24
static routers=192.168.42.1
static domain_name_servers=192.168.42.1
If you just need to assign a static IP address, to the device, because it is going to be setup as a hotspot or something, you can get away with the following.
interface wlan0
static ip_address=192.168.42.1/24
If you run into issues with it not assigning the address, check the /etc/network/interfaces file and make sure that the line that starts with “iface wlan0” says manual at the end and not static. If it says “iface wlan0 inet static”, change it to “iface wlan0 inet manual”