Category Archives: Free time

Part 1/3: Controlling LEDs using Raspberry Pi

In this post I will review, how to turn on or off LEDs using Raspberry Pi 2, Model B (RPi).

First we copy Raspbian linux to a microSD card, turn on RPi and connect to it using ssh.

We use three LEDs and each needs to be connected to each own positive supply of the circuit and ground, as well as, we needed laser cutting to get the perfect size. For the positive supply on RPi we use pins 18, 17 and 27 as seen on the scheme below:

RPi_GPIO

 

As the current would be too high if we connect the LED directly into the circuit, we need to add a resistor for each LED. As it is written in the Raspberry Pi spec, it can safely allow up to 16mA current. Our pins can supply 3.3V. Therefore to allow the LED to be the brightest, we can use 210Ohm  or stronger resistor. Using stronger resistor will result in the LED not being so bright.

In this example I am using 560Ohm resistor. I am also attaching a nice scheme for calculating the resistance of 4-band resistors:

Screen Shot 2016-02-04 at 11.09.35

 

To control a specific LED, we can “turn on” a specific LED using a Python library. First we need to set a pin as output and then we can turn it on (GPIO.HIGH) or off (GPIO.LOW). An example of a script that turns on a LED:

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
 
GPIO.setup(18,GPIO.OUT)
GPIO.output(18,GPIO.HIGH)

Physical result:

IMG_0161

Mac OSX Lion: Time Machine to PC share

There are problems backing up Mac OSX computers to network shares (other than Apple :)) because Apple uses some proprietary protocols (to better sell other products :)). Instead of searching workarounds such as creating virtual disks on remote shares, I’ve found out a nicer option by searching the web.

SOLUTION: Installation of
a) Netatalk – an open-source implementation of AppleTalk protocols
b) Avahi – system for multicast service discovery in local networks

I own an older desktop PC “Barsabass”, running Ubuntu 11.10, which also serves me as DLNA, file server and from now on also as Time Machine backup server. In the following a simple procedure to get Time Machine from Mac to PC working is described. You can further add other shares or properties (conf files are nicely documented).

INSTALLATION:

Step 1: Install netatalk and avahi packages.

apt-get install netatalk avahi-daemon

Step 2: Enable netatalk server by editing /etc/netatalk/afpd.conf. Add following line.

“Barsabass” -tcp

Step 3: Enable some Apple shares by editing /etc/netatalk/AppleVolumes.default. Add line containg path to share folder (= TimeMachine bakup location), name of share, allowed users.

/media/Dokumenti/bcpks/slavko_mbpro_tm “slavko_mbpro_tm” allow:slavkoz

Step 4: Enable netatalk server run parameters in /etc/default/netatalk.

CNID_METAD_RUN=yes
AFPD_RUN=yes
TIMELORD_RUN=yes

Step 5: Setup afpd for broadcast. Create file /etc/avahi/services/afpd.service.

<?xml version=”1.0″ standalone=’no’?><!–*-nxml-*–>
<!DOCTYPE service-group SYSTEM “avahi-service.dtd”>
<service-group>
<name replace-wildcards=”yes”>%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=Xserve</txt-record>
</service>
</service-group>

Step 6: Restart both services.

/etc/init.d/netatalk restart

restart avahi-daemon

Step 7: Use Time Machine backup and enjoy! Your configured share should be now visible like on the picture below. After you successful share access by Finder, you can select the network drive in Time Machine and begin backing up you Mac.

LG TV and .mkv via DLNA

My LG TV played .mkv files from USB, but not via DLNA. After selecting .mkv file, “This file is invalid” dialog showed and TV restarted.

I have used various DLNA servers on Windows, Linux and today I tried Serviio. I just deleted “transcoding” tag int “profiles.xml” for “LG TV” profile and videos are played smoothly (without transcoding on my AMD64 3200+, 2GB@333Mhz).

Another nice thing Serviio does is automatically identifying series, grouping them and showing half-watched videos.