Alexa-Controlled Remote Part II

So I got my new LEDs in, and lo and behold, it works!

To make sure that they were blinking, I wrote a quick Python script that toggled multiple pins (right now its hardcoded to just 1 pin, but I could have changed variables to toggle others).  This was very nice, as I could have it turn on every 15 seconds or so and watch it on my phone camera.

import RPi.GPIO as GPIO
import time

gpio_start = 18
gpio_end = 19


for x in range (gpio_start, gpio_end):
   GPIO.setup(x, GPIO.OUT)

while True:
   for y in range (gpio_start, gpio_end):
      GPIO.output(y, True)
      print 'on ', y
   for z in range (gpio_start, gpio_end):
      GPIO.output(z, False)
      print 'off ',z

Toggling pins through Python was nice and easy.

I can see the LEDs blink, but now I’m running into another problem.  My remote only has a range of 2 feet. Not very useful, considering the two things I want to control are about 12 feet apart.

I figured it had something to do with my resistors, and that they were too high, but I was scared of burning things out at the same time, so I didn’t just want to play around with any old value.

So, I pulled up a circuit simulator at, and drew up a schematic.  I was able to see that I was only pulling 8 mA of current through the resistor the way I had it set up.  What could I do differently?

First, I needed to look at the datasheet and see just how much amperage my LED could take.   I bought my LEDs from Adafruit ( and right there on the page, I saw.


100 mA continuous, 1A when pulsing.  So if I’m only going down to 8mA, I have room to grow.  I was okay going with the pulse, but I had to make sure I didn’t run my Python script if I was pulling more than 100mA.

Here is what I ended up settling on:


This drew 120 mA through the LED.  And, lo and behold, I now have a range of about 10 feet on the remote (maybe further, but my USB power cable was only so long to the pi).

So, now I could actually send commands to the projector to turn it on and off.  I was doing this through irsend (part of the lirc program).  I used a file generated from irrecord (also from lirc), and I ended up with the following.

begin remote

  name  projector.conf
  bits           16
  eps            30
  aeps          100

  header       9023  4400
  one           627  1597
  zero          627   485
  ptrail        630
  repeat       9027  2160
  pre_data_bits   16
  pre_data       0x4CB3
  gap          107281
  toggle_bit_mask 0x0

      begin codes
          KEY_POWER                0x40BF
          KEY_POWER2               0x748B
      end codes

end remote

I tried renaming the piece to projector, but apparently lirc requires you to put a .conf in there, so i tended up as projector.conf.  When I executed irsend, you have to specify projector.conf (and this file has to be at /etc/lirc/lircd.conf.  I haven’t found out where error messages for lirc just yet, so there is a lot of guesswork associated with this.

Next, I started working on my sound system.  Unfortunately, I could not get this to work whatsoever.  I had to put a -f on the irrecord to grab my remote input, but I could not replay it for the life of me.  I had not found any other templates in lirc’s remote database that worked either.  So I’m stumped on why that’s not working.

I think I’ll start playing with Python and LIRC next though, to feel like I’m making some good progress before I try and figure out why the sound system won’t respond to my LED.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s