Category Archives: Uncategorized

Howto: Arduino Due as MIDI HID device

1) Get the HIDUINO code from: https://github.com/ddiakopoulos/hiduino

2) Get the MIDI library for Arduino at http://sourceforge.net/projects/arduinomidilib/

3) Program the 16u2 chip with ICSP programmer:

../bin/avrdude -C avrdude.conf -c avrispmkII -p m16u2 -P usb -U flash:w:/Users/jouni/Downloads/hiduino-master/Compiled\ Firmwares/HIDUINO_MIDI.hex

To RECOVER I wrote on OS X:

cd /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/firmwares/atmega16u2

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -c usbasp -p m16u2 -U flash:w:Arduino-DUE-usbserial.hex

4) Edit the arduino midi library file MIDI.h and comment row sayin “typedef uint16_t word;” to get rid off compiler error (if occurs).

5) Upload for example the following code to Due:

#include <MIDI.h>
/*
Basic I/O MIDI tutorial
by Franky
28/07/2009
*/
#define LED 13   // LED pin on Arduino board
void setup() {
pinMode(LED, OUTPUT);
MIDI.begin(4);            	// Launch MIDI with default options
// input channel is set to 4
}
void loop() {
digitalWrite(LED,HIGH);     // Blink the LED
MIDI.sendNoteOn(42,127,1);  // Send a Note (pitch 42, velo 127 on channel 1)
delay(1000);	 // Wait for a second
MIDI.sendNoteOff(42,0,1);   // Stop the note
digitalWrite(LED,LOW);
}
#include <MIDI.h>/*  Basic I/O MIDI tutorial  by Franky  28/07/2009*/
#define LED 13   // LED pin on Arduino board
void setup() {  pinMode(LED, OUTPUT);  MIDI.begin(4);            	// Launch MIDI with default options	 // input channel is set to 4}
void loop() {
digitalWrite(LED,HIGH);     // Blink the LED    MIDI.sendNoteOn(42,127,1);  // Send a Note (pitch 42, velo 127 on channel 1)    delay(1000);	 // Wait for a second    MIDI.sendNoteOff(42,0,1);   // Stop the note    digitalWrite(LED,LOW);

}

Designing microcontroller project

Few reminders when designing an uC-project:

Inputs

General on inputs:

  • Primarily use first all external interrupt and analog pins. Make pads for unused “special” pins, for example external input/analog-pins.

Pulse measuring:

  • Do you need to measure pulses? Use external interrupts whenever possible, they are simple to do and really accurate

Outputs:

  • If generating pulse out by delay remember that interrupts make the signal jitter.

sed

To replace content of file in unix / linux, use sed.

Basic use, first try outputting to terminal:

sed s/blue/black/ file.txt

you can then do either

sed s/blue/black/ file.txt > replaced.txt
or
sed -i s/blue/black/ file.txt

Last command makes changes directly to file.

If you need to use non-alphabetic-characters, use \ – char in front of them. For example:

sed s/file\.txt/nonfile\.txt/ filetoreplace

More, much more : http://www.grymoire.com/Unix/Sed.html#uh-8

Goodbye Spotify

After almost two years of paying premium account I’ve decided to detach from Spotify and start buying music in CD-format.

Why?

Spotify updates itself without asking user permission. There is no way to even turn it off from the application. Why it bothers me? It’s a serious security risk. Spotify can plant any code on my machine. Probably they won’t plant any harmless functionality but think about if someone breaks into Spotify’s update system? Too easy to distribute any kind of malicious code.

Spotify adds cluttering features and redesigns UI too often. In latest update Spotify was one click away from sending my local mp3’s to Spotify. Actually based on my first rant it could have done it automatically based on their attitude and respect on users.

Spotify doesn’t pay artist enough. Yeah, I know what you’re saying: artist can decide if they want to publish music on spotify or not. I wish it was that simple.

Spotify redirects all paying customers to ask in getsatisfaction.com but fails to answer to questions. I’m paying 9,99€ per month and I wish they would have bothered to answer to my concern there but no. I’m paying customer and I think I can demand customer service. But nada. And I’m not the only one, go ahead and look.

So thanks but no thanks. I try to stick to owning the music I want to listen and not walk in a leash of Spotify and follow their rules. It’s my money.

Howto: Safari cookies – Session only

If you want to block Safari from remembering your cookies (and you should if you care about your privacy) you can force Safari from writing cookies to file with following steps:

1) Quit Safari
2) Remove the Cookies-file from /Users/[yourusername]/Library/Cookies. The file is called Cookies.plist
3) Open Safari and visit some random page that uses Cookies
4) Now you should have the Cookies.plist file again in the folder
5) Open the Cookies.plist in Finder “Get Info” and choose “Locked”