This site is still under construction, but I'm blogging on it anyway.
Feel free to follow me on Twitter
So I got my Arduino Duemilanove earlier this week, and I've been completely stoked. After getting blinky going, I promptly took out my breadboard from the plastic container, assembled a jumble of jumper wires, resistors, LED and buttons into what became an on-off switch for the LED. Fascinating. Bloody gorgeous. What next?
Well, since I have the button presses as digital input, and the LED as digital out, I thought a neat project would be to record a 3 second button input pattern, and replay that pattern through the LED. That would familiarize me with some of the Arduino's code, and would just be really fun to see live.
For the LED, I connected a jumper cable from the digital out (pin 11) to the breadboard. Then I connected a 1k ohm resistor to the LED, then a jumper cable from the LED to ground. For the next part of the circuit, I connected a jumper cable from a digital read slot (pin 2) on the Arduino the breadboard. I then added a pull-down resistor of 2k ohms from the jumper cable to ground, and lastly, I connected the 5V slot to the button via another jumper cable. This mini-project took about 1-2 hours (coding, after a day of coding, can be tiresome on the ol' noggin), followed by 1 hour of button pushing in awe :)
In any case, I've included a video of it, and the code. Word of warning about the code: It can definitely be done more efficiently (ex: arbitrarily large arrays = fail), I am a computer science major after all, but I also have better things to do:P I haven't really looked at the Arduino API, and it's pretty much just hacked together. Anyway, here's a video, a sketch of the circuits, and the code:

Code:
// set pin numbers:
const int buttonPin = 7; // the number of the pushbutton pin
const int ledPin = 11; // the number of the LED pin
// Variables will change:
int buttonState; // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin
// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers
int hold = 0; //keeps state of the button
int beeps = 0; //number of button pushes
int start = 0; // are we starting a new pattern?
long startTime = 0;
long duration = 3000; //duration of the recording
long delayArray[200]; //no dynamic arrays! randomly large number. shut up.
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);
// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
buttonState = reading;
if (reading == LOW){
hold = 0; //otherwise, we're still holding the button!
}
if(hold == 0){ //if the button was let go
if( (start == 1))
{
long time = millis();
if ((time - startTime) < duration ){
if (buttonState == HIGH){
beeps++;
delayArray[beeps] = time;
reading = LOW;
hold = 1;
}
}
else{
//replay the signals on the led
int i = 0;
long lastTime = delayArray[0];
long now, next, span;
digitalWrite(ledPin, HIGH);
delay(150);
digitalWrite(ledPin, LOW);
for(i=1; i<=beeps; ++i){
next = delayArray[i];
now = millis();
span = now + (next-lastTime);
while( (span - now) > 0){
now = millis();
}
digitalWrite(ledPin, HIGH);
delay(150);
digitalWrite(ledPin, LOW);
lastTime = next;
}
start = 0;
beeps = 0;
}
}
else{
beeps = 0;
if(buttonState == HIGH){
start = 1;
startTime = millis();
delayArray[0] = startTime;
reading = LOW;
hold = 1;
}
}
}
}
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonState = reading;
}
So I got my Arduino Duemilanove earlier this week, and I've been completely stoked. I've had no previous work with circuitry aside from some high school classwork, and all I could remember from that was V=IR... and I had forgotten what the 'I' stood for:P So why this sudden interest? Because electronics are awesome, and have now become extremely accessible to create and personalize.
The Arduino, simply said, is a ridiculously easy-to-program microcontroller. You stick an LED onto the Arduino, write a program, upload it via USB, and boom, something happens. It's great for anyone interested in one day building their own robots, pet projects, or any kind of circuit, but have had no previous experience. It's even great for people with no experience in programming, since the programming aspect is extremely simple to grasp: there is a loop function, and it sends and receives information to and from the Arduino on each cycle. The Arduino software comes with tons of plug-n-play examples, with concise and understandable comments. Out of the box, the Arduino is an extremely user-friendly experience.
Three cheers for the simplicity, but why would someone even want one? Well, if you're interested in rapid prototyping, this is a great solution, but most people don't even know what 'prototyping' means. So if you're one of those people, like me at one point, and have even an inkling of interest in electronics or circuitry, this is the most accessible tool to get magic happening. The high learning curve of coding and interfacing with AVRs, and all that other jazz is just not there with this handy tool. The grunt work is done for you, and you can go straight to testing. It's a great learning tool, and you can finally apply those principles you learned in physics! It's also dirt cheap, you can get one for around $30 USD, and starter kits with resistors, LEDs, and other useful components are available as well. But the most important reason is this:
There's something completely magical about seeing a working Arduino that you crafted. When I first loaded up the blinking LED program, I felt something real, something extremely tangible. With that first blink, a thousand ideas of how I can control that light came into my head, and the possibilities are truly endless. And that wasn't even code I personally wrote!
Coming from the world of software, where most of my code and thought goes into making things happen on screen and not really into something I take with me and use offline, making this simple circuit in the flesh made me feel like what I was doing was more... real. It made me feel the same way I did when I first started programming: awed. For this reason alone, I recommend people to at least give this little circuit board a whirl. It's bound to please.
Anyone working with CouchDB for any large-scale project would probably like to be able to shard their database and/or use a cluster of couch instances. Those of you interested in doing this would most likely turn to CouchDB-Lounge. Unfortunately, getting Lounge to work is a huge pain in the ass. It took me a while to figure out why things weren't working, what packages I was missing and what code I had to alter (Lounge is not completely free of hardcoded configs!). There weren't too many useful sites out there, so this post is for all those out there struggling with CouchDB-Lounge and need some help. If I missed something, please comment.
Firstly, I'm assuming a fresh install of some Linux distro (I used ubuntu). Note: Configuring for OS X is different and apparently a bit harder to do for some reason. I was going down that path until I spoke with Randall Leeds (tilgovi, one of the Lounge devs) on the #couchdb IRC channel, and he warned me the install hasn't been properly tested on Macs, and more tweaking might be involved.
So, for dumbproxy to work, you need to download and compile json-c as directed on the Lounge wiki, but also remember to get the python-pyicu package. Once you get that running, read THIS. Fix this bug, otherwise, your nginx process will be running with the wrong config.
For smartproxy, you'll need python-cjson package, and for replicator, you'll need the pycurl package. I think I ran into more problems, but I'll check my logs and get back to this post in a bit.
Now here's the meat of the problem. After running this and setting up my shards.conf file to point to two couch instances on different ports, when I'd submit any request to the main lounge instance (running off port 6984), my requests were virtually ignored. So after running around reading the sparse documentation, the immense log files and reading the code, I found this line in replication_notifier.py:
me = 'http://' + socket.gethostname() + ':5984/' (line 40)
which retrieved my laptop name, and completely ignored my conf files! So it was effectively trying to use http://malini-laptop:5984 as the main couch instance, and my laptop name didn't resolve to 127.0.0.1, so my requests were shot to nowhere. In the end, I fixed this by adding another section in my local.ini conf file that contained the URL for the main couch instance, and I changed that line to pull from the conf file. Beware of this problem if your configuration points to anywhere but (hostname):5984!
Aside from configuration problems, Lounge does what it's supposed to do, which is pretty sweet. I hope this prevented people from wasting their time trying to figure out what was wrong with their configuration:)
Ou, as a side note, it might be useful for those using python-couchdb to modify Server's 'create' method. Lounge uses nginx, and the current python-couchdb (0.6.1) seems to assume you're running Apache or some other web server, since it currently sends no headers with the PUT request. Nginx throws up HTTP errors when it sees that there are no headers (it assumes it's a chunked request, which it does not handle), so I patched it to send:
self.resource.put(validate_dbname(name), headers={'Content-Length':'0'}) [line 17]
This tells nginx that you're simply making a PUT request with no data.
So I am now in San Francisco.
I'm here on an internship, doing more web development! But instead of Python/Django, it's PHP/Zend. You'd think it would be a pretty easy transition from one MVC web framework to another, but that was not the case! For one thing, Django's cute little ORM spoiled me:(
Zend is a very powerful tool with great libraries, but that fact is not easily recognizable to a beginner. For those who want to get the gist of this framework by running through the QuickStart, good luck to you. Really. I've also been spoiled by Django's amazing Tutorial and Documentation. The QuickStart changed drastically over the last two weeks, due to the new Zend release. This should be good news, except, it's still unfinished. Yes, STILL. The last QuickStart guide had typos, left out information, and didn't use hypertext to its full potential:P Meaning, it was confusing, and you needed to delve into the heavy Zend Documentation to get a simple question answered. And yes, the new QuickStart guide is no better. It is shorter (...yay? I guess. A win for the impatient), but does not hold enough information. It just tells you what SOME lines of code do and what the Zend parser looks for, but it doesn't really go much into depth. It barely even scratches the surface. And there are still chunks of text missing (scroll to the bottom). So yeah. Have fun, beginners! :P
My recommendation to a beginner is, yes, run through the QuickStart, but don't expect many answers to it. All I really learned about Zend from the QuickStart was information regarding what Zend needs to know to parse code properly, and the structure of a normal web application. The real magic lies in the Zend library. I started playing with Zend_Db at work, and it's a pretty good tool. Try using the Zend_Db alone without a Mapper for one of your models. It will be a fun learning exercise that will help shape your Zend and database/querying skills. If you're a beginner to web development and are looking for a friendly, quick way to start a website, my recommendation to you is to skip PHP/Zend and check out Django. It's prettier and the docs are nicer. But maybe that's just my superficiality talking.
Be ready for some posts with substance! Finally!
Yes, I know I don't have comments yet. And yes, I know that sucks. My Javascript/JQuery knowledge right now is close to zero. But I'm working on it!