Thursday, April 18, 2013


I have looked into GPIO programming in Python. Looks ok so I ordered some basic (and cheap) stuff:

a full-sized breadboard
50 F/M patch wires
assorted colored LEDs with resisters
assorted colored push-button switches

After I figure out programming those simple devices, I plan to move on to controlling the LEDs from my iPhone.

Once that works, I plan to move on to more challenging (and expensive) devices.

Friday, April 12, 2013

My Pi chapter 2

Post 2

Something I forgot about initial setup: U.S. users -- be sure to change the default keyboard from UK to US. Otherwise, lots of luck finding important special characters.

Here's my Python program (copy/try it if you wish):
# Compute Pi to 10,000 places
# recoded using the algorithm from "ABC Programmers Handbook", Geurts, et al
def arccot(x, unity):
    sum = xpower = unity // x
    n = 3
    sign = -1
    while 1:
        xpower = xpower // (x*x)
        term = xpower // n
        if not term:
        sum += sign * term
        sign = -sign
        n += 2
    return sum

def pi(digits):
    unity = 10**(digits + 10)
    pi = 4 * (4*arccot(5, unity) - arccot(239, unity))
    return pi // 10**10

ans = str(pi(10000))
ans = ans[0:1]+'.'+ans[1:] # insert decimal point
print ans
BTW: this takes 4 seconds on the Pi and .6 second on my iMac. Same answer, though.

What I'd like to do with the Pi: (sounds like a 3rd-graders essay)
My grand-daughter & husband have a vegetable farm. They have built a cold storage building and need to trick a window AC unit into keeping it cooled to 40 degrees F. They also could use other automation aids: a) alarm on the lock, motion detector, soil moisture reading, plus lots more. I'd like them to be able to control the Pi via a local WAN by an iPhone. This will be a challenge!

More as I progress.

Dick Haight

Rpi: getting started

Post 1: First of Who knows?

I ordered my Raspberry Pi in February. I resisted paying any more than the legendary $35. That made it take longer. I also ordered a fast class 10 16GB SD card so it would have plenty of free space ($28).

This took so long that I swiped an SD card from my camera and downloaded a Linux image onto my iMac. To copy it on to the chip in proper format I had to learn about the ancient Unix "dd" command (I worked on Unix at Bell Labs in the 1970s -- never thought I use dd again).

I had just finished all of this when Fedex guy arrived with the other chip in a tiny padded envelope (4-ton truck to deliver a half-ounce package).

I have also bought an HDMI-to-VGA cable so I could use a borrowed old LCD monitor. You could program from a VGA monitor but it was fuzzy on any resolution greater than 640x480, which now days is useless on the Web. This was a waste of $20+ and a lot of time messing with the config file.

Also, I acquired a plastic case and a tiny USB WIFI plugin ($13). WIFI setup was pretty easy but the device caused a headache. When I typed on my old left-over keyboard I got a bunch of repeated keystrokes. It wasn't obvious to me that the WIFI device was taking too much current but the problem stopped the instant that I plugged the cords into a powered USB hub (another $16).

I borrowed an HDMI-to-DVI cable & monitor. They work fine. Here's how my Pi looks now.
The little blue light is on the WIFI adapter. The keyboard/mouse (when needed) go on the powered hub.

I mentioned "when needed" because I have worked out how to access the Pi from my iMac. I set up "ssh" (remote login program) on the Pi and use the same thing from Terminal on the Mac. Now I only need a monitor/keyboard when I screw something up.

Next issue: a Python Pi program for your bemusement and what I'd like to do with the Pi.

Dick Haight