Published by António Lopes on March 19, 2013

Don’t know what “recursion” is? Google explains:


Published by António Lopes on March 10, 2013

Back in 2007, US researchers have simulated half a virtual brain of a mouse on a supercomputer. Interestingly, Ray Kurzweil, in his 2005 book “The Singularity is Near“, accurately predicted the amount of computing power necessary for that scientific achievement.

What’s really interesting is the prediction that he made for 2013. Check this graphic:

Supercomputer power

(Image source)

Click here to read more

Published by António Lopes on March 9, 2013
Categories: Books, Funny, Geek, Images, Internet, Personal

I’m reading the third book1 now… guess which part I’m at!

George R. R. Martin will kill a Stark every single time someone asks him how long will it take until the next book comes out

  1. A Storm of Swords []
Published by António Lopes on March 6, 2013
Categories: DIY, Geek, Images, Science, Technology

Continuing the work with analog sensors on the Raspberry Pi, I decided to test the PulseSensor‘s behavior in building a pulse sensing application. The Pulse Sensor is a well-designed plug-and-play heart-rate sensor for Arduino but considering that it’s a simple analog sensor that sends values between 0 and 1023, it’s easy enough to use  with the MCP3008 ADC on the RPi.

Click here to see the code

I’m starting a new semester where I’ll be teaching about Concurrent and Distributed Programming. This cartoon pretty much sums up the whole thing:

Concurrency: it works... most of the time

Source: Geek And Poke

Published by António Lopes on June 28, 2012

Since I need to do some serious work on the Arduino platform in the near future, I decided to have a look at all the material I had lying around to make sure I have everything I need for my next project. However, I discovered a particular object that I didn’t know what it was.

Light-depended resistor

A light-dependent resistor

I quickly took a picture of it and shared on Twitter (which is actually much better than Google for this kind of stuff) and, right away, several people replied pointing out that the mysterious object was in fact a photoresistor, or a light-dependent resistor.

Basically, this small sensor outputs its sensitivity to light and in this case, it produces a value between 0 (in very dark places) and 1023 (close to the sun) that can be read by an Arduino board through one of the analog input pins.

Since I also had a small buzzer that I could connect to the Arduino, the next step became obvious: to build a cheap-ass theremin. Before lunch, preferably… And it was indeed quite easy to build and program. Here’s the schematic for the whole thing:

Theremin schematic

The schematic for the cheap-ass home-made theremin

Basically, you need: a buzzer, a photoresistor, an Arduino board (pictured here is the Ethernet shield since the Arduino I used was the Ethernet variant), a couple of resistors, a mini-breadboard and some wires for the connections. In case you’re wondering how to do this kind of schematics, I used Fritzing.

As for the code, it’s also quite simple: you just need to get the photoresistor sensor value from the chosen analog input pin (in this case, A0) – a value between 0 and 1023 (awesome tutorial here) – and convert it to a frequency, ranging from 0 to 2500Hz (I chose this particular frequency because it sounded loud enough but I’m not sure how high it can go) and send it to the digital output pin (in this case, 4). The buzzing part is a bit trickier but this tutorial explains it quite well.

Here’s the complete code:

int prPin = 0; // Pin where the photo resistor is connected to
int prReading; // The analog reading from the photoresistor
int buzzerPin = 4; // Connect Buzzer to Pin 4
long buzzerFreq; // The frequency to buzz the buzzer
// You can experiment with these values: long BUZZ_FREQ_MAX = 2500; // Maximum frequency for the buzzer
long PR_MAX = 1023; // Maximum value for the photoresistor

void setup() {     pinMode(buzzerPin, OUTPUT); // set a pin for buzzer output

void loop() {
    prReading = analogRead(prPin); // Values 0-1023
    buzzerFreq = (prReading * BUZZ_FREQ_MAX) / PR_MAX;
    buzz(buzzerPin, buzzerFreq, 10);

void buzz(int targetPin, long frequency, long length) {
    long delayValue = 1000000/frequency/2;
    long numCycles = frequency * length/ 1000;
    for (long i=0; i < numCycles; i++){

And here’s the video with a small demo:


I know this is nothing like a real theremin, but considering the limited output sound that the buzzer can produce (and the ridiculous amount of time I spent with this – around 20 minutes), this is probably the best I can do with this stuff.

Published by António Lopes on June 25, 2012
Categories: Funny, Images, Personal, Random

Realistic living statue

What makes this differ from other living statues I’ve seen is the details on the painting. It really looked like one of those old bronze statues that you see in most touristic areas. If he just had the patience and will to include some pigeon crap, it would have been flawless.

Spotted yesterday in beautiful Cascais.

Published by António Lopes on May 11, 2012


View of Sintra’s palace from my home using my telescope and the iPhone.

Published by António Lopes on March 30, 2012
Categories: Funny, Images, Random
Published by António Lopes on March 2, 2012
Categories: Images, Personal, Random, Society

There has always been a discussion about Agnosticism and Atheism. Are they mutually exclusive or are they supposed to be combined in a two-dimensional scale? It’s a difficult question to tackle but Zach Weiner’s post is one of the best texts I read on this subject.

He makes an interesting point about the question of whether or not you’re agnostic should come before the question of whether or not you’re atheist. Here’s his proposal in graphical terms:

Want to know if you're an agnostic or an atheist? Follow this simple flow chart!

Want to know if you're an agnostic or an atheist? Follow this simple flow chart!

His point is that if a person is agnostic (i.e. a person that believes it is impossible to know if there’s a deity), then there isn’t really a point about discussing whether or not you’re an atheist (i.e. a person that doesn’t believe in the existence of deities) because you’ve already stated that it is impossible to know if there is a God or not.

The other interesting point that he tackles is the absolute certainty with which one can affirm he/she is an Agnostic or Atheist. It all comes down to the knowledge you possess at this point and things can (and most probably will) change in the future.

So, for now, I’d make his words my own:

I like to just call myself “irreligious.” Whether I’m agnostic or gnostic or atheist or whatever is really dependent on what we’re talking about. But I know for a fact that I don’t attend a place of worship, and don’t assume any books are sacred.