Wednesday, May 20, 2015

Control an LED remotely using SSH(Secure Shell)

1. Make sure an LED can be switched ON/OFF locally with a Raspberry Pi. See instructions here.

2. Enable the SSH server using raspi-config:

Type in the terminal:

sudo raspi-config

Select 'Advanced Options'.


Select 'A4 SSH'.













Select 'Enable'.




















3. Get the IP address with the ifconfig command.

You will get the IP address such as 192.168.10.183.

4. Download and run PuTTY with a Windows PC.

5. Key in the IP address as the host name and keep the port as 22:
6. Click YES.

7. Login to Raspberry Pi.
7. Enter the commands below to control the LED to be ON/OFF:

sudo python

>>> import RPi.GPIO as GPIO
>>> GPIO.setmode(GPIO.BCM)
>>> GPIO.setup(4,GPIO.OUT)
>>> GPIO.output(4,1)

LED is turned on!


>>> GPIO.output(4,0)

And the LED is turned OFF with a remote PC!

No comments:

Post a Comment