Category Archives: Coding

Creating with code – programming skills

Makey Makey Drum Set Using Scratch

In my coding class the assignment was to create a game controller using my Makey Makey and Scratch. I used a belt wrapped around my wrist to attach the ground:

IMG_4426

And I used 5 upside down seltzer cans and a box to create the controller:

IMG_4427I’m not that well versed in Scratch yet, and I’m just learning a few tricks like how to “Broadcast,” but I did take an original drum machine from the Scratch site to make my own project. I really learned more good basics by playing with that. My problem is that I take so much time to do almost anything, and then I get distracted by my Raspberry Pi – I try to save and import my project into the stand-alone software on the Pi, and then try to fix my browser that keeps corrupting my profile…

Here is the whole thing in action with the controller:

If I make the controller again I would spray paint the bottoms of the cans different colors and use cloth for the cover of the box – not wrapping paper.

Raspberry Pi Used Automatically to Complain to Comcast for Slow Speeds

A Comcast user has used a Raspberry Pi to create a device that will complain to Comcast when service goes well below the speed he’s promised.

Code Below:

#!/usr/bin/python
import os
import sys
import csv
import datetime
import time
import twitter

def test():

#run speedtest-cli
print ‘running test’
a = os.popen(“python /home/pi/speedtest/speedtest-cli –simple”).read()
print ‘ran’
#split the 3 line result (ping,down,up)
lines = a.split(‘\n’)
print a
ts = time.time()
date =datetime.datetime.fromtimestamp(ts).strftime(‘%Y-%m-%d %H:%M:%S’)
#if speedtest could not connect set the speeds to 0
if “Cannot” in a:
p = 100
d = 0
u = 0
#extract the values for ping down and up values
else:
p = lines[0][6:11]
d = lines[1][10:14]
u = lines[2][8:12]
print date,p, d, u
#save the data to file for local network plotting
out_file = open(‘/var/www/assets/data.csv’, ‘a’)
writer = csv.writer(out_file)
writer.writerow((ts*1000,p,d,u))
out_file.close()

#connect to twitter
TOKEN=””
TOKEN_KEY=””
CON_SEC=””
CON_SEC_KEY=””

my_auth = twitter.OAuth(TOKEN,TOKEN_KEY,CON_SEC,CON_SEC_KEY)
twit = twitter.Twitter(auth=my_auth)

#try to tweet if speedtest couldnt even connet. Probably wont work if the internet is down
if “Cannot” in a:
try:
tweet=”Hey @Comcast @ComcastCares why is my internet down? I pay for 150down\\10up in Washington DC? #comcastoutage #comcast”
twit.statuses.update(status=tweet)
except:
pass

# tweet if down speed is less than whatever I set
elif eval(d)<50:
print “trying to tweet”
try:
# i know there must be a better way than to do (str(int(eval())))
tweet=”Hey @Comcast why is my internet speed ” + str(int(eval(d))) + “down\\” + str(int(eval(u))) + “up when I pay for 150down\\10up in Washington DC? @ComcastCares @xfinity #comcast #speedtest”
twit.statuses.update(status=tweet)
except Exception,e:
print str(e)
pass
return

if __name__ == ‘__main__’:
test()
print ‘completed’

Goodbye Wheezy, Hello Jessie

I really wanted to get an email client onto my Pi, but it seemed like Wheezy wasn’t up to the task so I had to break-up with her. It was a clean break and I’m sure she’s ok about it. I quickly found Jessie and am hoping we can be together for a while.

jessie

First I had to get a larger sim card as Jessie weighs in at 3.5 Gb. Then I reformatted it using SDFormatter from SD Association.

Screen Shot 2016-01-30 at 10.07.32 AM

I downloaded the image onto my Mac and moved it over to the Pi and installed it with Noobs. Jessie really does seem better and worth the switch. Config is easier and it comes with a nice Office set-up. I couldn’t get the default email client, Claws, to work so I downloaded Icedove, a much better client, the open version of Thunderbird. The add/replace software app didn’t work for me, so I had to learn how to download through the terminal. This advice on doing that was so helpful – I’m glad I found it when I needed it.

2000px-Icedove-icon.svg

Now I’m using both Icedove and Iceweasel on the Pi, have an Office suite, have about 20 Gbs of extra space, and learned a good amount along the way.

Raspberry Pi Up and Running

My Raspberry Pi works!

All for about $60 plus shipping, and because I already had a keyboard/mouse and HDMI monitor, I have a newly functioning computer. The Raspbian OS includes everything I need, web browser, Scratch, text editor, and a few other things I’m looking forward to exploring.

Raspberry Pi 2 Model B w/wireless.

IMG_4396

I hadn’t used Linux for a long time – It was very easy to set up the default graphical OS.

IMG_4399

Yes! I was pretty happy to see that…

IMG_4400

With ethernet, before I set up WiFi.

IMG_4406

It’s a good idea to go through the config tool carefully. Be sure to change your keyboard layout from gb to us.

IMG_4408

I really didn’t have any problems – a little bit of trouble getting wifi to connect to my wireless router, but it caught another one just fine.

Peter Oakes’s start-up guide was really helpful:

Makey Makey Appetizer

I spent the morning with my new Makey Makey. I really like its design and ease of use. The quick start guide was all I needed to get going and find software to use with it. I went to the fridge and found what I could, which was mostly things to make appetizers – 18 month gouda, chorizo sausage, a hot pepper, an apple and an old can of seltzer.

IMG_1447

IMG_1448

Be Stoked

IMG_1450

Makey Makey Appetizer Video

IMG_1452 IMG_1453

The problem with this set-up is that it’s too easy to eat the equipment.

Scratch

I’ve just started using the MIT site Scratch. It’s a place where you can learn how to use code to create fun projects. I played with it for a while and lost myself in time. At some point I think I’ll be able to share a project here, but I’m not sure how, or if I’d really want to show you the silliness I created yet! Screen Shot 2016-01-18 at 5.46.35 PM