DM2009 Introduction to Arduino

In this week’s lesson, we were introduced to Arduino Mega 2560. It is a microcontroller board which has 54 digital input/output pins and 16 analog inputs. It is very easy to use – simply connect it to a computer with a USB cable – plug and play.

In order to allow interaction between MAX and Arduino, a library called Maxuino was also installed. Before we could start tinkering with anything, there were some configurations to be done:

  1. In Arduino 3, select the right board and port used. (Tools -> board -> Arduino Mega 2560 ; Tools ->port -> usbmodem.??.tty
  2. Open up the Standard Firmata under Examples and upload it into the board

Then get a copy of SparkFun Inventor’s Kit for Arduino and get started!

Yi Xiang and I grouped together and we had fun connecting up the wires and components. I found that it is easier to follow the schematic diagram than the illustration. In our exercise, we used a photoresistor (as analog input), a LED (as digital output), a 330 ohms resistor, a 10k ohms resistor, and some jumper wires. The connection is shown in the diagram below:

Arduino and breadboard

Arduino and breadboard

After opening up Maxuino-gui, update the board and port used. Then we tested the input and output of Arduino in Maxuino patch with GUI. The GUI is very useful in letting us to control and observe the arduino’s input and output in real time. To program this exercise, the patch was modified as shown in the figure below:

Maxuino Interface

Maxuino Interface

Basically this is how it works:

  1. The program takes in the input value from the photoresistor (which change its resistance according to light intensity)
  2. The input value is compared with a certain value (e.g. 0.5)
  3. When the value exceeds 0.5, it will trigger the ouput to go to “on” state (LED connected to that output pin will light up)
  4. At the same time, the input values are also converted to larger number using “scale”. The converted values are fed into “mtof” and “cycle~” to produce a sinusoidal wave. Finally a speaker is connected to output the sound waves. Therefore, the photoresistor has a direct effect on the sound wave produced.
  5. Later on, we modified it to allow the control of movie playback using the photoresistor.

Overall, it was a fun lesson!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s