MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment and proprietary programming language developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages.
Although MATLAB is intended primarily for numerical computing, an optional toolbox uses the MuPAD symbolic engine allowing access to symbolic computing abilities. An additional package, Simulink, adds graphical multi-domain simulation and model-based design for dynamic and embedded systems.
This code is wrotter to connect the arduino, sending data from it to matlab and show it in an interface;
Processing
Processing is an open-source computer programming language and integrated development environment (IDE) built for the electronic arts, new media art, and visual design communities with the purpose of teaching non-programmers the fundamentals of computer programming in a visual context. The Processing language builds on the Java language, but uses a simplified syntax and a graphics user interface.
This software is very simple to use (looks like arduino IDE) and on the web site of Processing there is a reference's page where you can find all the commands.
The basic "Hello World!" code in Processing is:
println( "Hello world!" );
Individual assignment
SO for this week is to create a user interface for my input device . So, what I planned was to create an interface that simulates the change of sensor positioning and also launches a melody when clicking on a button on the interface.
The first step is to establish a communication between Arduino and Python. For this step ,I start by a simple code which allows me to retrieve only the necessary data bits, I removed the extra data with the two instructions in lines 33 and 34. It's very important to install the serial package to import it and also the function of line 11 which reads from the serial port declared in its parameter (here in my code is the COM34).
After the creation of the interface was easy for me, in the create_widgets function I created a canva and two buttons using the tk.Canvas and tk.Button functions, choosing for the first one (tk.Canvas) the color and dimensions and for the second one (tk.Button) the text of each button and the name of the function that will be called when we click on the button.
This is the final interface:
The small inner rectangle has been added following the addition of this instruction in the updateCanvas function to simulate the encoder positioning change.
now adding the functionality of the "tonemelody" button which will send the letter "B" to the arduino via the serial port and this was done by the tune function [ with the following instruction : self.mySerial.write("B".encode())
And to retrieve this data (the letter send "B"), I added the following code that allow to turn on the tone when the arduino recieve "B":
You will find here all the code files( file.ino & file.py ) . And this a video that shows this small project.