Mt. Nokogiri (鋸山), Nihon-ji (日本寺) and its huge buddha (大仏)

I made a trip to the mountain Nokogiri (鋸山) in Chiba prefecture. This mountain is renown for having the biggest statue of buddha (2nd and 3rd would be those in Nara and Kamakura) of all Japan. This statue belongs to Nihonji (lit. 'Japan temple') which is now under restoration (May 2014). Not only that, it is also a nice and easy hill to hike with all kinds of sculptures on the way to the submit. No special skills or equipment are required since the path is paved.

There are several ways you can get to Mt. Nokogiri. The map above describes the one I would suggest if you live not very far from Kawasaki. On the East exit of Kawasaki JR station there is a bus terminal. Go to the platform 22 and wait for the bus that goes to Kisarazu (timetable). The price of the bus is about 1440 yen one-way. Once you get to Kisarazu, take the JR Uchibō train line towards Hota station (Kanjis on the map). The price for the train is about 670 yen. Therefore, in total the transportation fees would rise up to the amount of 4220 yen.

Note: you can also get off one station before Hota station, at Hama-kanaya (浜金谷) station, if you prefer to take the cable car which brings you right near the top. If you live near Kurihama (久里浜), there is a ferry that goes from Kurihama to Kanaya (timetable) and costs about 720 yen one-way.

From Hota station, you turn right (towards the bank) and then walk for about 80m. Turn right again and pass under the train rails. You should start seeing some signs with the kanji 遊歩道. Follow those signs, they will take you to the entrance which is about 1.5Km away from Hota station.

The 1.5Km span from Hota station to the entrance to the mountain (see picture below) was perhaps the most enjoyable part of the whole trip. Since most tourists opt for the cable car approach, that path was mostly free from people. Perfect for portraying the beautiful scenes of the japanese countryside. Since I went in Spring flowers were specially beautiful.

At the entrance to the mountain, you must pay an entrance fee of about 600 yen (400 yen for children). In exchange, you receive a map of the mountain in English or Japanese (maps in Japanese, map in English).

The first thing I noticed when I entered the mountain was the songbirds. In particular, the penetrating sound produced by some Woodpecker birds (キツツキ) which were hammering the cortex of tree where they lied catched my attention (listen). Perhaps they were happy for having enough earthworms to eat.

Just a few minutes of steps and you'll find the famous buddha statue (daibutsu). Let's be honest, after having seen several of them I lost the ability to get surprised. However, I was really surprised when I found something that I had overview while looking up the information for the trip: the 100 shaku kannon. This is a relief sculpture carved in quarry stone and hidden near the top of the mountain. This one really made my day, and reminded me of those famous relief sculptures and monuments in Petra.

This post wouldn't be complete without pictures from the observation deck on top of Nokogiri. The first one shows the cost of the Bōsō peninsula, and the second one is Tokyo bay. On a clear day (usually in Winter) I read that Mt. Fuji can be seen from there.

Reading a .wav file in Java

Although in Java it is possible to get data directly from an audio device, there are no standard libraries for reading and parsing a wave (.wav) audio file. If you just want to make some simple experiments with wave files, instead of searching for a full-featured library you could use the tip proposed in this post. The wave format is rather simple: a part that states the format of the samples (e.g.: stereo 16bit 44100Hz) and a part with the samples themselves.

00 "RIFF"
04 File size in bytes - 8
08 "WAVE"

[Format chunk]
12 "fmt " (format chunk mark)
16  Format chunk size - 8 (16 for PCM)
20  Format tag (1 for PCM)
22  Number of Channels (e.g.: 2)
24  SamplesPerSec (e.g.: 8000Hz)
28  AvgBytesPerSec = (Sample Rate * BytesPerFrame).
32  BlockAlign = BytesPerFrame = (BitsPerSample * Channels)/8 
34  BitsPerSample (e.g.: 8)

[Data chunk]
36 "data"
40 Data chunk size - 8
44 Frame_0: sample_channel0[0], sample_channel1[0], ..
   Frame_1: sample_channel0[1], sample_channel1[1], ..
   Frame_n: sample_channel0[n], sample_channel1[n], ..

If you don't believe me you can check it by yourself:

$ arecord -f U8 -c 1 -r 8000 -d 5 pepe.wav
Recording WAVE 'pepe.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
$ ls -l pepe.wav 
-rw-r--r-- 1 dsl dsl 40044 Mar  2 20:14 pepe.wav
$ od -A d -N 44 -w4 -v -t a pepe.wav 
0000000   R   I   F   F
0000008   W   A   V   E
0000012   f   m   t  sp
0000036   d   a   t   a
$ od -A d -N 44 -w4 -v -t u2 pepe.wav 
0000000 18770 17990   RIFF
0000004 40036     0   file size (40044) - 8)
0000008 16727 17750   WAVE
0000012 28006  8308   fmt
0000016    16     0   16 bytes of format data
0000020     1     1   1 channel
0000024  8000     0   8000 samples/sec
0000028  8000     0   8000 bytes/sec
0000032     1     8   8 bits/sample (1 byte/frame)
0000036 24932 24948   ata
0000040 40000     0   4000 samples

Now here is the point. Suppose that we just want to play with a wave file in a specific format. Then, we can skip the first 44 format bytes and go straight to the data. In particular, if the format of the wave file is "mono 8bit" things get as simple as this:

$ vi
public class pepe {
  public static void main(String[] args) {
    int bytes, cursor, unsigned;
    try {
      FileInputStream s = new FileInputStream("./pepe.wav");
      BufferedInputStream b = new BufferedInputStream(s);
      byte[] data = new byte[128];
      cursor = 0;
      while ((bytes = > 0) {
        // do something
        for(int i=0; i<bytes; i++) {
                unsigned = data[i] & 0xFF; // Java..
                System.out.println(cursor + " " + unsigned);
    } catch(Exception e) {
$ javac
$ java pepe > data.txt
$ gnuplot
gnuplot> set size ratio 0.3
gnuplot> plot "data.txt" with lines

Hope that's useful for you.

Ubuntu Spanish accents | Tildes en Ubuntu.

This is a method for writing Spanish accents on Ubuntu when you don't have a Spanish keyboard. I tested it on Ubuntu 12.0.4 LTS (classic desktop). I am using a Japanese keyboard with an English environment.

System tools -> System settings -> Keyboard layouts -> Layout ->
Options -> Compose key option -> Right Alt

Note: if you can't find "System tools" menu, execute the command 'gnome-control-center'

Then you can write Spanish accents as follows:

RightAlt-a + ' = á

RightAlt-e + ' = é
RightAlt-i + ' = í
RightAlt-o + ' = ó
RightAlt-u + ' = ú
RightAlt-n + - = ñ
RightAlt-? + ? = ¿

Note: RigthAlt is the Alt key on the right side of the keyboard.

Recycling an IR LED for timelapse movies with Arduino

In this post, we are going to reuse the infrared LED inside a recycled remote controller for periodically activating the shutter of a digital camera in order to create a timelapse video like the following one.

In Japan there are many recycling shops where you can get old electronic junk for a cheap price. It's a very ecological way to learn about electronics, so I went ahead and bought a DVD remote controller at hard off.

Most remote controllers are based on infrared communication. Although humans can't see infrared light, I found out that the CCDs inside most cameras do. This can be useful for making your own infrared night vision camera (maybe a future post), or just for quickly checking whether your remote control is working or not.

Now let's go inside the device: remove the batteries and screws, and open it up by pressure. A remote controller typically consists of the following elements:
  • A case made of ABS plastic.
  • A PCB containing button switches and the control circuitry.
  • A button panel made of silicone rubber. Each button has a layer of conductive paint underneath. When pressed it connects button switches on the PCB board.

Here is a sketch of the remote controller I got from hard off. It's a very simple circuit consisting of:
  • Electrolytic Capacitor (47uF 10V): removes high frequency noise or peaks in the power supply. A general rule is to use one that supports at least double the normal voltage (10V > 2x3V).
  • Ceramic resonator (4MHz): it works like quartz crystals but has bigger tolerance, it's cheaper and smaller (includes built-in capacitors). Used to create the carrier wave for infrared communication.
  • Resistor (2.2 Ohm): not sure why such a low value.
  • Transistor (C3203 NPN): for switching the LED on and off.
  • IR LED: a LED that emits light in the infrared range (e.g., 950nm).
  • IC: the chip where all the logic takes place. I couldn't identify which IC was used here, but I'm guessing it's something similar to the PCA8521. Button switches are wired to the IC, which (I guess) performs internally a loop (it could be done with flip-flops too) and polls the status of each button switch. Next, the IC selects the corresponding code from an internal ROM (customized during fabrication) and sends a modulated pulse wave through the IR LED.
For more information about remote controllers check this article.

In this post we are going to recycle the IR LED and save the remaining electronic components for a future circuit. An easy way to desolder components is to use a desoldering braid.

Once you desolder the LED, connect it to an Arduino digital pin using a resistor to limit the current running through (Arduino can handle up to 40mA). I'm using a 5V power supply and the LED's voltage drop is 1V so a 220 Ohm resistor will give me 18mA which is good enough to power the LED.
The final step wildly depends on your camera model. I have a Sony NEX-5 and fortunately there was a nice person that made the corresponding Arduino code public here. For different models you have to google a bit, and maybe modify existing arduino code, but it should not be too difficult (here you have code for Nikon cameras). Once you have taken interval pictures, put them together in a video with a command such:
mencoder -idx -nosound -noskip -ovc lavc -lavcopts vcodec=mjpeg -o output-rec.avi -mf fps=15 'mf://@files.txt'