Monday, April 28, 2014
Fabric is cool.
Tuesday, January 21, 2014
Programming Makey Makey clicks to send strings
Sending a string
One way to send a string instead of a keystroke is to modify the Mouse Button Events in the makey.ino file. To make a left mouse click send 'Hello World':- In the Arduino IDE, open the makey-makey.ino file.
- In the main code file, *not* the settings.h, find the lines
- Comment out the Mouse.Press line, and replace it with a Keyboard.print
- Upload the sketch. Pin A1 is the Makey left-mouse click. Touch the Ground and Pin A1 to try it.
if (inputs[i].keyCode == MOUSE_LEFT) {
Mouse.press(MOUSE_LEFT);
}
if (inputs[i].keyCode == MOUSE_LEFT) {
//Mouse.press(MOUSE_LEFT);
Keyboard.print("Hello World.");
}
Sending a carriage return with button click
Modify the settings.h file this time, since only one key is being modified. For example, pin A0 defaults to a right-mouse-click...change it to send KEY_RETURN.
int keyCodes[NUM_INPUTS] = {
// top side of the makey makey board
KEY_UP_ARROW, // up arrow pad
KEY_DOWN_ARROW, // down arrow pad
KEY_LEFT_ARROW, // left arrow pad
KEY_RIGHT_ARROW, // right arrow pad
' ', // space button pad
MOUSE_LEFT, // click button pad
// female header on the back left side
'w', // pin D5
'a', // pin D4
's', // pin D3
'd', // pin D2
'f', // pin D1
'g', // pin D0
// female header on the back right side
MOUSE_MOVE_UP, // pin A5
MOUSE_MOVE_DOWN, // pin A4
MOUSE_MOVE_LEFT, // pin A3
MOUSE_MOVE_RIGHT, // pin A2
MOUSE_LEFT, // pin A1
// COMMENT MOUSE_RIGHT TO REPLACE IT WITH KEY_RETURN
//MOUSE_RIGHT // pin A0
KEY_RETURN // pin A0
};
Sending a carriage in sketch code
Instead or modifying the inits, you can write it in one of the Mouse.press routines. Keyboard.write(KEY_RETURN);Monday, January 20, 2014
Using a Makey-Makey with Ubuntu
I've spent a lot of time working with software, but had never been exposed to the basic principles of electronics. The Makey-Makey is a great introduction to the world of circuitry. Its 'cool trick' is hacking just about anything into a keyboard. There's a lot of video of folks wiring all kinds of household items into input devices.
But underlying all the fun stuff is real first look at how electronic hardware works. The Sparkfun electronic hobbyist's site has an excellent collection of tutorials presenting the fundamental science and application of electronic circuitry.
Arduino is a very popular open-source electronics prototyping platform...your local RadioShack should offer a variety of Arduino-ready components. The Makey Makey is programmed using the Arduino IDE (Integrated Development Environment). Here's how to install the Arduino IDE in Ubuntu. (I used Arduino IDE version 1.0.5, and Ubuntu version 13.10.)
First, install the Arduino IDE. The one in the Ubuntu repository worked fine for me.sudo apt-get install arduinoThis will install the IDE software to: /usr/share/arduino/
To use the Arduino IDE with Makey-Makey, you'll need to install a driver. Download the zipped driver with:
wget https://dlnmh9ip6v2uc.cloudfront.net/tutorialimages/MaKey_MaKey_QuickStart/MaKeyMaKey-13-8-12.zip
Then Unzip the driver to the IDE's hardware directory:
unzip MaKeyMaKey-13-8-12.zip -d /usr/share/arduino/hardware
If that worked properly, you should see the Makey-Makey listed in the Board menu.
To modify basic functionality of the Makey, you'll need to grab the source code.
Get and extract the source:
wget https://dlnmh9ip6v2uc.cloudfront.net/tutorialimages/MaKey_MaKey_QuickStart/MaKeyMaKey-13-8-12.zipMove it your home/sketchbook's
mv hardware/Makey ~/sketchbook/hardware/
Permissions
To ensure your IDE can communicate with the Makey, add your user to the following three groups, like so:sudo usermod -a -G dialout $USER sudo usermod -a -G tty $USER sudo usermod -a -G uucp $USER
Resolve Ubuntu ModemManager conflicts
For the IDE to be able to update the Makey settings, you'll need edit ModemManager blacklist settings. (This fix is taken from discussions here and here.) Using your favorite text editor, you'll need to create/edit a file at:sudo vi /etc/udev/rules.d/77-mm-arduino-blacklist.rulesIn your editor, append the following line to that file:
ATTRS{idVendor}=="1b4f", ATTRS{idProduct}=="2b74", ENV{ID_MM_DEVICE_IGNORE}="1"
Save the file.Unplug your Makey. Close the IDE, Logout/Login. Plug Makey back in. From there, you'll be ready to reprogram your Makey, following along with the MaKey MaKey Quickstart Guide (Part 2).
Monday, March 25, 2013
Using python pymssql to query SQLServer from linux
sudo apt-get install freetds
sudo pip install pymssql
Create entries for your sqlservers in /etc/freetds/freetds.conf like so:
[dev01]
host = YOUR_SQL_SERVER_HOST
port = 1433
tds version = 8.0
Here's a simple script using it:
import pymssql
import getpass
pwd = getpass.getpass()
conn = pymssql.connect(host='YOUR_SQL_SERVER_HOST',
user='YOUR_DOMAIN\\YOUR_USERNAME', password=pwd)
cur = conn.cursor()
cur.execute('use YOUR_DB')
query = "select top 10 id, name, lastmodifieddate from campaign"
cur.execute(query)
for row in cur:
print "{0}\n{1}\n{2}\n".format(row[0], row[1], row[2])
Friday, March 8, 2013
sqsh -- install, configure, usage
sudo apt-get install freetds
sudo apt-get install sqsh
Create entries for your sqlservers in /etc/freetds/freetds.conf like so:
[dev01]
host = dev01server
port = 1433
tds version = 8.0
Create settings file in ~/.sqshrc
\set username=MYDOMAIN\myusername
\set password=
\set style=vert
Usage:
user@box:~$ sqsh -Sdev01
sqsh-2.1 Copyright (C) 1995-2001 Scott C. Gray
This is free software with ABSOLUTELY NO WARRANTY
For more information type '\warranty'
1> use testdb
2> go
1> select field1, field2 from table where field1 = 'test';
2> go
field1: test
field2: other data
(1 row affected)
1> exit
user@box:~$
Tuesday, February 26, 2013
access remote django dev server from local browser
To access a remote Django development server from your local browser....
On the local host, SSH to the remote host:
$ ssh -v -L 9000:localhost:8000 <the remote address>
On the remote host, run the Django dev server:
/path/to/my/django/project$ python manage.py runserver 0.0.0.0:8000
On the local host, go to http://localhost:9000 in the browser
Or...
Using LocalForward in your ~/.ssh/config, add entry
Host myremote
User eliot
HostName my.remotehost.com
LocalForward 9000 localhost:8000
Thursday, February 14, 2013
SQuirrel SQL client for Ubuntu
Get it from here: http://www.squirrelsql.org/
Configuring it is a little tricky...use the guide here:
http://informatics.malariagen.net/2011/08/15/squirrel-sql-a-nice-database-gui-frontend-for-ubuntu/
To configure it for MySQL as well, follow similar steps after installing the mysql-jdbc driver.
sudo apt-get install libmysql-java

