Sunday, November 2, 2014

Interfacing Arduino Uno with MATLAB

Step-1: Download the ArduinoIO MATLAB support file from here 
Step-2: Download the Source file from here 

Step-3: Add the downloaded ArduinoIO folder to your MATLAB bin path 
in my case it is "C:\Program Files\MATLAB\R2012a\bin"

Step-4: Connect your Arduino board to your PC/Laptop

Step-5: Open Arduino IDE Tool and copy the downloaded source file on to the new sketch file. Compile it and upload it on to the Arduino Uno board.

Step-6: Now Open your MATLAB and type "arduino" on command prompt. You will see some scrolling message. Then type "a=arduino('COMx'), x is your COM port number which is assigned to your board. 

Step-7: If you want to read analog port data then type "b=a.analogRead(0)" this will read analog port A0 data. If you want read/write any digital pin use these instructions


 a.digitalwrite(13,0) ;

a=arduino('COM3'); // In my case it is connected to COM3 port


Step-1: Write this code in Arduino IDE tool and upload this code on to your board. 
void setup()
  while (!Serial) {
      ; // wait for serial port to connect. Needed for Leonardo only

void loop()
  Serial.print("Hello World!");
 // Write your code here

Step-2: Open MATLAB and type this code in matlab file and run the code

s = serial('COM3'); // In my case it is connected to COM3 port
fprintf(s, 'Your serial data goes here');
out = fscanf(s);
% Data Analysis 
clear s;

ATmega16A/32 USB Boot-loader Circuit/Programmer

Fig.1 shows the ATmega16A USB boot-loader circuit. Integrate all the components shown in the circuit. Download the AVR USB Flash programmer tool and upload your .HEX file on to the microcontroller. The circuit can be used as a separate programmer or it can be integrated on to your project.

Fig.1 ATmega16A USB Boot-loader circuit

 Fig.2 shows the ATmega16A/32 USB boot-loader and Development kit. Connect all the components and upload your .HEX file on to the controller. This circuit can be used to program your controllers and also can be used as a standard development board. It has character LCD and SPI connections. This circuit is best for students doing embedded system projects on ATmega16A controller.
Fig.2 ATmega16A/32 USB Boot-loader and Development kit circuit