Introduction: Remote Control Light Switch Flicker

In this instructable we are going to be building a small robot, controlled wirelessly with an android phone, that flicks a light switch on and off.

The brains of the robot will be a Raspberry Pi. The Pi will be controlled by an android phone over an FTP server.

To use the android phone as a remote control we're going to be running python scripts on SL4A

Step 1: Parts List

Parts

Step 2: Making the Arm

Picture of Making the Arm

First we need to make an arm which the motor can spin to make the light.

I made this piece out of lexxan.

It mates nicely with the GM8 motor.

The design of your arm is completely up to your creativity as long as its well secured to the motor.

Step 3: Wiring It Up

Picture of Wiring It Up

Mount the breadboard, battery pack, Raspberry Pi, and motor to a sheet of plastic or wood.

Wire up the motor, RPi, and battery like above.

Step 4: Programming the Pi

How is our phone going to communicate with the pi?

The pi will start an ftp server on boot.

The android phone will have an app that can write to a file on the ftp server.

The raspberry pi will read from this file and spin the motor based on the contents of the file.

To do this first boot up the pi

Copy the python program switchFlicker5.py into the /etc directory of the RPi

This program will read from a text file that our phone can write to. The program will then spin the motor based on the content of the file.

We now need a way for this program to run on boot.

We also need to start an ftp server on boot so the phone can communicate with the pi.

We do this by editing the RC.local file.

Open the file RC.local in Nano by:

  • opening terminal
  • CD to root
  • CD to etc
  • nano rc.local

now edit the RC.local file like this.

#!/bin/sh -e

sudo service proftpd status &

cd

sudo python switchFlicker5.py

_IP=$(hostname -I) || true

if[ "$_IP"]; then

printf "My IP address is $s\n" " S_IP"

fi

exit 0

Step 5: Setting Up the Phone

We now need a program on your phone that can write data to files on the raspberry pi's ftp server

We'll be doing this with SL4A.

Install SL4A from https://code.google.com/p/android-scripting/ on your android phone

Open the above file in a text editor and edit all the commented lines of code. (ip address, username, password, etc)

Add the file to your SL4A directory.

Step 6: Test It Out

You're done!

Just power the pi, wait a minute for the pi to boot, and then run the python app.

The python app will ask you what you want to do. Say ON to turn the lights on, OFF to turn the lights off, and EXIT to stop.

Comments

About This Instructable

2,015views

14favorites

License:

Bio: me@swal.xyz
More by Call Me Swal:CNC Made From GarbageWorking Spider-Man Web ShooterMake a TumblyBOT: Flipping Spinning Tumbling Robot
Add instructable to: