Sunday, November 8, 2015

I've made a LEGO car with Caterpillar

I assembled "Tamiya Educational Construction Series No.100 : Track and Wheel Set (70100)" and attached them into the LEGO car I assembled last time.

I used 2 shafts out of the 5 shafts in the set. I connected caterpillar made of rubbers. I tried this set with my son, but this is more difficult than the slim tire set we tried last time.

Sunday, November 1, 2015

I've made a LEGO car with double-gearbox and slim tire set

I made a LEGO car with the following two modules and a breadboard:
  • Tamiya Educational Construction Series No.168 : Double Gearbox (Left/Right Independent 4-Speed)
  • Tamiya Education Construction Series No.193 : Slim Tire Set (36mm, 55mm Dia.)
I and my son assembled the double-gearbox with 344.2:1 gear ratio. My son was saying "I like mechanical things". He looked enjoying assembling. We also attached the slime tire set. We used LEGO blocks to make the car body. We used blocks with a hole and inserted shafts. I connected the motor, breadboard, and battery box. By switching battery's plus and minus contacts, the car moved forward and backward.

I'm planning to connect the car into Raspberry Pi 2 so that it can turn left and right with various verocity. 

Saturday, October 17, 2015

I've controlled character LCD through Web

I've controlled character LCD via command line last time. I will control the LCD via Web this time.

I installed apache2 and php5. Then, I called  /usr/sbin/i2cset and i2cget via exec command from PHP script. i2cset can't run because apache2 run on www-data user by default. /var/log/apache2/error.log shows there is no root privilege.

I added the following lines into /etc/sudoers:

www-data ALL=(ALL) NOPASSWD:/usr/sbin/i2cget
www-data ALL=(ALL) NOPASSWD:/usr/sbin/i2cset

Now I can call "sudo /usr/sbin/i2cset" by exec command. I can access it from Android Tablet by setting PHP URL.

Sunday, October 11, 2015

I've tried AQM1602 16x2 character LCD

I bought character LCD with I2C interface. LCD itself costs 450 yen. I soldered the LCD to 2.54mm pitch pin header. I put resistors and condensers on the bread board.

I connected the LCD into Raspberry Pi2's 3.3V, GND, and SDA signals. I didn't put pull-up resistors because those signals are pulled-up internally by Raspberry Pi 2.

I2C address of the LCD is 0x3E. "i2cdetect" command returns 0x3E correctly.

LCD shows characters by sending commands via I2C according to initialize steps written in the usage manual of the LCD. Sometimes commands failed, but they succeeds if I put long wait time. I found that the command fails if the I2C baud rate is 100000 of default value. If I change it by 50000, command succeeds stably. We can change the baud rate by writing the following lines into /boot/config.txt:


Saturday, October 10, 2015

I've tried SG92R: Micro servo motor

It is the first time that I use a servo motor. I hear servo motors are often used for robots. DC motors torn round and round, but servo motors rotate only limited angle. They have different applications.

SG92R have 3 signal lines: 5V, GND, and control signal. 4 AAA battery should be connected to 5V signal. I connected the control signal to Raspberry Pi 2's PWM port. We can control rotate angle by using PWM port.

I used "softServo", which is one of wiringPi library, to control the servo motor. We can download wiringPi by using:

git clone git://

Running ./build in wiringPi folder will make wiringPi library under /usr/local/lib folder. However, This library doesn't include softServo.c, which is required to control server motor. I have to change Makefile so that it build softServo.c too. wiringPi library have already exist in /usr/lib at NOOBS 1.4.2, so,

gcc -o test test.c -lwiringPi

cause an missing function error because it first search /usr/lib/libwiringPi.xx first. So, I use the following command:

gcc -o test test.c -L/usr/local/lib -lwiringPi

I run the command and the servo motor moved by 120 degree with Brrr-r-r sound.

Tuesday, August 4, 2015

I've tried MPU-6050: 3-axis gyroscope and a 3-axis accelerometer

I bought a Raspberry Pi 2 on April, but I left it as it is for a while. I started using Raspberry Pi 2 again recently. I decided to try some sensor modules because Raspberry Pi can control those devices easily.

I bought MPU-6050 by 400 yen. It has 3-axis gyroscope, a 3-axis accelerometer, and temperature sensor. It can be controlled via I2C. I soldered pin-headers and inserted it into a breadboard.

There are open source libraries of I2C communication for Raspberry Pi. I can find the assigned address for I2C by using "i2cdetect" command. I referred Reading data from the MPU-6050 on the Raspberry Pi for how to control MPU-6050. 3D graphics shows well how gyroscope detects the movement.

I could learn characteristic of analog electronic circuit by actually trying sensors.