Feeds:
Posts
Comments

If you’ve never programmed a computer, you should. There’s nothing like it in the whole world. When you program a computer, it does exactly what you tell it to do. It’s like designing a machine — any machine, like a car, like a faucet, like a gas-hinge for a door — using math and instructions. It’s awesome in the truest sense: it can fill you with awe.

A computer is the most complicated machine you’ll ever use. It’s made of billions of micro-miniaturized transistors that can be configured to run any program you can imagine. But when you sit down at the keyboard and write a line of code, those transistors do what you tell them to.

Most of us will never build a car. Pretty much none of us will ever create an aviation system. Design a building. Lay out a city.

Those are complicated machines, those things, and they’re off-limits to the likes of you and me. But a computer is like, ten times more complicated, and it will dance to any tune you play. You can learn to write simple code in an afternoon. Start with a language like Python, which was written to give non-programmers an easier way to make the machine dance to their tune. Even if you only write code for one day, one afternoon, you have to do it. Computers can control you or they can lighten your work — if you want to be in charge of your machines, you have to learn to write code.

[…] and I realized that feeling “stuck” is not due to not knowing what to do, but to knowing exactly what to do, and being afraid to act upon this insight.

This slideshow requires JavaScript.

Geek Sunday

Imagine that it’s a Sunday morning, and you are pretty bored and want to do something relaxing and a little bit of fun. Imagine that you talked about LEDs and Arduinos with a colleague two days before, and so you have checked your electronics storage and know perfectly how many LEDs you still have (too many, I can assure you). Why not do something fun with them? For example, LEDs that play along a MIDI track :)

So, what I did was:

  1. find out a nice MIDI track, a not too complex one if possible; I decided for “Twenty One” by Jessica Curry, from the “Dear Esther” soundtrack: I love that theme, and it’s basically a single instrument (a piano). I already had a MIDI version of it, which I simplified a little bit (I basically removed the counter-theme)
  2. find out how many 220 Ω resistors you have (turns out: about 40, that go along perfectly with the 36+ red LEDs that I had)
  3. find out how many shift registers (the famous 595 IC) you have: not so many, unfortunately. I only had 3, so I can pilot up to 24 LEDs, or 2 octaves. I would have preferred 3 octaves…

I put together the circuit (I tried to resemble a piano keyboard, with two rows of “keys”; if I had more LEDs of a different color, the result would have been better. Also, I didn’t want to solder anything, so the positioning on the breadboard cannot be as precise as one would like. I also needed two more LEDs, that I had to switch on and off from the Arduino side without the 595) and the code: it uses the MIDI library to receive the “note on/off” messages from the serial line (you can see the RX LED switching on the Arduino in the video), and it switches the LEDs according to the pitches that it receives. Since I only had 2 octaves, I had to transpose the theme one octave down, and since the MIDI file had 3 tracks but I had just one line of LEDs, I had to prioritize the tracks: basically, if the same note is played by two tracks, the track with the highest priority would decide when to stop the note. I achieved this by reordering the tracks in the MIDI file, so that the ones with a highest channel number have a highest priority.

The last step from the Arduino point of view was install the dear old Hiduino firmware: basically it allows the Arduino to be recognized as a MIDI device, instead of a serial device, so that it can communicate with multimedia apps on the computer side. Of course, once you rewrite the firmware, you need to upload the sketches from the ISP header.

Finally, I fired up Jack (the low latency audio daemon), Rosegarden (to reproduce the MIDI file) and KMidiMon (to monitor the MIDI events), I connected the Arduino to the computer, routed the MIDI lines to all the “clients”, and voilà!

This slideshow requires JavaScript.

P.S.: nevermind the names of some of the variables in the code: they come from previous experiments with the 595s, and I haven’t changed them due to laziness…

C’è stato un periodo in cui si tendeva a prendere per i fondelli EXPO 2015, ogni volta che ci passavano davanti o gli articoli che descrivevano le iniziative ad esso legate, o le pubblicità in giro per la metropolitana o sui giornali, bollando il tutto con frasi del tipo “tanto non verrà mai realizzato”, “chissà quanto verrà a costare”, “un Paese come il nostro non si merita questo tipo di eventi perchè non è in grado di valorizzarli” etc.

Il tutto è stato incentivato dal festival di scandali che EXPO ha prodotto in questi anni, e dalla quantità di persone che ci hanno mangiato alla grande, essenzialmente con i soldi pubblici.

Eppure, da un anno a questa parte ho conosciuto diversi colleghi che hanno lavorato e lavorano per EXPO, su progetti diversi e con diverse responsabilità; colleghi come me, quindi assegnisti al Poli, una delle categorie direi meno privilegiate di sempre, all’interno di un sistema universitario come il nostro, con tutti i suoi problemi.

Ed ho smesso di prendere per il c**o EXPO, perchè mi sembra francamente di mancare di rispetto a chi per EXPO ci lavora veramente, a chi non ha mai visto un centesimo in più (se non il suo normale stipendio), e quindi a chi merita di vedere EXPO avere un minimo di successo e non merita di vederlo fallire, seppellito da tutte le maledizioni e sfortune che la gente comune, che vede solo chi ha rubato dei soldi, non esita a lanciargli, specie nei social media.

… sentiamoci liberi invece di continuare a maledire chi i soldi li ha rubati veramente :)

“È stata una canzone bellissima, davvero, ma così triste…” disse la ragazza, prendendo il coraggio a due mani.
“La maggior parte delle belle storie lo è” replicò il menestrello.

La scuola

L’ultima cosa sul concetto di pace, a proposito dei romani. Per i romani la pace incominciava quando riuscivano a imporre il proprio dominio su un altro popolo. Nel linguaggio comune utilizzavano il termine pax anche per dire sta zitto tu, basta, non mi scocciare.

Ma la pace è un’altra cosa: il pacifico non è un pacioccone, per cui voi parlate, parlate sempre. Fate come fanno i francescani, che dicono pace e bene. E quando vedete che il concetto di pace non si unisce a quello di bene, gridate. Perché certe volte la pace va gridata, certe volte la pace va urlata!

Follow

Get every new post delivered to your Inbox.

Join 439 other followers