Control your LEDs with your TV remote?! || Arduino IR Tutorial

I created a [XamarinFormsIoT] Windows Core IoT project which can control LEDs and play sounds on a Raspberry PI 3. I used a portable dependency interface to expose the GPIO controller which only exists in the UWP project. GPIO is used to control the LEDs. I also ordered an IR receiver so I can detect IR signals from a remote and it works!

Next I need to [find] a UWP library for LIRC.

The [Arduino-IRremote] has a C++ library that can be converted to UWP.

I followed the idea from the video below.

[How to Control the GPIO on a Raspberry Pi with an IR Remote]

Adafruit: [IR (Infrared) Receiver Sensor]

[Raspberry Pis, Remotes & IR Receivers!]

[Xamarin Components]

[Play wav file in Raspberry PI with Windows IoT Core]

[XamarinMediaManager]

[Xamarin Forms: Hello Blinky]

[Windows 10 IoT Core : Setting Startup App]

[UWP on Xbox One]

Hardware: ASUS X99A Motherboard

Motherboard: $229 ($30 rebate) [ASUS X99-A] [amazon] [newegg]

Memory: $119 CORSAIR Vengeance LPX 16GB (2 x 8GB) 288-Pin DDR4 2666 [amazon] [newegg]

Processor: $399 Intel Core i7-6800K Processor (3.60 GHz) [amazon] [newegg]

CPU Cooler: $41.99 [Cooler Master GeminII S524 Version 2 CPU Air Cooler with 5 Direct Contact Heat Pipes]

Power Supply: $144.99 [Corsair RMi Series, RM850i, 850 Watt (850W)]

Power Supply: $130.27 EVGA SuperNOVA 850W G3 [amazon] [newegg]

Case: $89.97 [DIYPC Skyline-07-R Black/Red SPCC ATX Full Tower]

Wireless Networking: $112.99 [ASUS 4×4 802.11AC Wireless-AC3100 PCIe] [amazon] [driver]

Harddrive: $259.99 WD Blue 1TB Internal SSD Solid State Drive [amazon] [newegg]

Graphics: $579.99 [ASUS GeForce GTX 1080 8GB ROG STRIX]

[Processors]

[Memory]

[CPU Cooler]

[win10]

Raspberry PI 2 with Leap

The Leap Motion Controller requires ARM-9 or better and to make work with the Raspberry PI 2 I used a proxy HTTP server to work with the Raspberry PI 2. The Raspberry PI 2 controls servos based on the data from the leap. Each finger on the leap controls a different servo.

The project in action:

Details about the code:

The proxy sends JSON data for the finger rotations (in degrees).

{
  "thumb": 27.815885630721692,
  "index": 8.8111549114070726,
  "middle": 16.216426372741033,
  "ring": 29.267951404867844,
  "pinky": 86.043786182477533
}

The script:

#!/usr/bin/env python

import RPi.GPIO as GPIO
import datetime
import time
import urllib2
import threading
import json

servo_pin2 = 18
servo_pin3 = 22

# 60 degrees / 0.1seconds 
servo_speed = 0.1

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)

GPIO.setup(servo_pin2, GPIO.OUT)
GPIO.setup(servo_pin3, GPIO.OUT)

last_time = datetime.datetime.now() 
current_time = datetime.datetime.now() 

accuracy = 0.01
rotation1 = 90
rotation2 = 90
rotation3 = 90
rotation4 = 90
rotation5 = 90
timeRotation1 = 0
timeRotation2 = 0
timeRotation3 = 0
timeRotation4 = 0
timeRotation5 = 0
targetRotation1 = 90
targetRotation2 = 90
targetRotation3 = 90
targetRotation4 = 90
targetRotation5 = 90

pulse2 = GPIO.PWM(servo_pin2, 50)
pulse3 = GPIO.PWM(servo_pin3, 50)

logTime = datetime.datetime.now()

stayAlive = True

def getRotation(rotation):
  if (rotation > 90.0):
   return 180
  if (rotation > 45.0):
   return 90
  else:
   return 0

def newTarget():
 global targetRotation1
 global targetRotation2
 global targetRotation3
 global targetRotation4
 global targetRotation5
 while (stayAlive):
  content = urllib2.urlopen("http://192.168.2.97").read()
  #print (content)
  jsonObject = json.loads(content) 
  #print (jsonObject)
  #for key in jsonObject:
  # print (key)
  #print ("index: " + str(jsonObject["index"]))
  targetRotation1 = getRotation(jsonObject["thumb"])
  targetRotation2 = getRotation(jsonObject["index"])
  targetRotation3 = getRotation(jsonObject["middle"])
  targetRotation4 = getRotation(jsonObject["ring"])
  targetRotation5 = getRotation(jsonObject["pinky"])
  time.sleep(0)
 print ("Thread complete.")
 return

webThread = threading.Thread(target=newTarget, args=(), kwargs={})
webThread.start()

def log():
 global logTime
 global timeRotation2
 global timeRotation3
 global targetRotation2
 global targetRotation3
 if (logTime < datetime.datetime.now()):
  logTime = datetime.datetime.now() + datetime.timedelta(0, 0.5)
  #print "****"
  #print ("2: TargetRotation: " + str(targetRotation2) + " Time: "+str(timeRotation2))
  #print ("3: TargetRotation: " + str(targetRotation3) + " Time: "+str(timeRotation3))
 return

def reset(pulse):
 pulse.start(7.5);
 pulse.ChangeDutyCycle(7.5)
 time.sleep(0.5)
 pulse.ChangeDutyCycle(0)
 return

def compare(timeRotation, rotation, targetRotation):
 global deltaTime
 if (timeRotation >= 100):
  return 0.25
 elif (rotation == targetRotation):
  if (timeRotation >= 0.0):
   return timeRotation - deltaTime.total_seconds()
  else:
   return timeRotation;
 else:
  print "targetRotation changed."
  return 100

def update(pulse, timeRotation, targetRotation):
 cycle = 0
 if (timeRotation >= 100):
  cycle = 0
  if (targetRotation == 90):
   cycle = 7.5
  elif (targetRotation == 0):
   cycle = 2.5
  else:
   cycle = 12.5
  print ("Cycle: "+str(cycle))
  pulse.ChangeDutyCycle(cycle)
 elif (timeRotation >= 0.0 and ((timeRotation - deltaTime.total_seconds()) <= 0.0)):
  pulse.ChangeDutyCycle(0)
  print ("Cycle: "+str(cycle))
 return targetRotation

try:
 reset(pulse2)
 reset(pulse3)
 time.sleep(1)
 print "setup complete"

 while True:
  
  last_time = current_time 
  current_time = datetime.datetime.now() 
  deltaTime = current_time - last_time;

  log()
  timeRotation2 = compare(timeRotation2, rotation2, targetRotation2)
  timeRotation3 = compare(timeRotation3, rotation3, targetRotation3)
  rotation2 = update(pulse2, timeRotation2, targetRotation2);
  rotation3 = update(pulse3, timeRotation3, targetRotation3);

  time.sleep(0);
  
except KeyboardInterrupt:

 print '\r\nProgram shutdown.'
 stayAlive = False
 time.sleep(1)
 GPIO.cleanup();
 print '\r\nProgam complete.'

[LeapServer]

ASUS P5N-D Motherboard Specifications

I didn’t realize my older desktop is 10 years old. That explains the power fault crashes…
[specs]

Old motherboard: [ASUS P5N-D Motherboard Specifications] [manual]

Old Graphics Card: [EVGA GeForce 9800 GT]

NVIDIA: [Min VR Specs]

The lowest end replacements have comments suggesting the card runs hot. 90F+

[EVGA GeForce GTX 1060 One Fan]

[EVGA GeForce GTX 1060 Two Fans]

[Blade Pro Equivalent With Component Prices]

Other desktop: [ASUS Rampage IV Extreme] [$]

Suggestions from Carl:
* [1GB SSD]
* [ASUS Sabertooth Z170-S] [$]
* [ASUS Sabertooth Z170-MARK-1] [$]
* [PC Part Picker]