Interface and Application Programming

What is the assignment?

write an application that interfaces with an input &/or output device that you made. and compare as many tool options as possible

The Goal

My goal try python and processing also to use the button on my weak7 board to interface with processing code.

Python

After I watched Niel Lecture I decided to try Python which is open source high-level programing language. I Opened the from Python website I clicked on git started then I saw a link for those who are new completely to programming there are three books for people with zero experience in programming. I will read them for sure in my free time because I want really to learn Python. I search on youtube and then I found a great tutorial about Arduino and python which is a series of lessons that teach you how to make Arduino work with python. I will spare time for you to not watch the first two lessons (you must thank me for that).It's about dowloading the softwares so I downloaded these softwares and I must say I use windows so if you are using another system download which works with your system. So I download python 2.7.15, not python 3 version because the first one has all the libraries but python 3 may not have some libraries also I chose x32, not x64 because of the same reason then I downloaded pyserial-2.7.win32.exe which is a library allow pyhton to lesten and talk through it. then I download vpython.





After I download Vpython I clicked on VIDLE which was on the desktop to start writing programs. VIDLE is a page you write your program on it smilier to Arduino IDE. I wrote a simple programe which is hello world then I clicked on RUN-->Run modules then it was printed on python shell.

I wanted to try Python, but I didnt hava time I'm currently busy with my fianl Project. If I have time I will tested if I didnt I think procesing is enough.

Processing

I downloaded processimg from here then I started to learn about it from a bool called getting started with processing. This book helped me to know basic things on processing from making simple shapes to making applications to interface with other devices.

The first thing I learned is to make a circle by writing ellipse(100,100,40,40); this means write a circle in the cordinate (100,100) which have the width and hight of 40pixels. Then I learned that the function size deterimen the size of Display Window for example if I write size(200,200) this means the hight and width of the window will be 200.



Then I learned the other shapes such as traungle, rectangle and more. So I make a simple code thet compine all of them. I will put below an image from the book explaning how to make these shapes.



I been through the book and I learned how to make an application integrate with the mouse. First I learned that void setup is like in Arduino it will run the firs time and I can here write the size of the window, the color of the shape. When the mouse move the circle will generate following the mouse. From the book I learned that I can make only one circle folloing the mouse and this can happen by adding background in draw function. so when ever the

    
        void setup()// the command below will run one time only
{
 size(480, 120);// the width and hight of the window
 fill(0,150);// the color of the circle
 noStroke();// there will be no outline for the circle

}
void draw()// here the code will coninue to run

{
 background(204);// the color of the background
 ellipse(mouseX, mouseY, 9, 9);// a circle with x-y cordenate follow the mouse with width,hieght of 9px
 
}
           
           
           

To add the program to my page I learned that from Duaa on her intrface week she put a tutorial on that also she expline how so you can visit her page.



After learning from the book and seeing some student work like Darshan I learned how to make the code. Also in Processing there is examples regarding serial which give you a ready code for processing and Arduino. You can see the examples by clicking on file then Examples then go down and you will find Serial. In this week I used The last board I made in output week which has Atmege328p.

I first understand the example on processing also learned Alot from Darshan board(see his work). I made a new Arduino code and I edit Darshen processing code then I upload the code but I faced a problem the code didn't work. I tried a lot like changing the code but nothing works. So I brought Arduino and I upload the code to see if it will work, and it did work. One thing about uploading, I notice in examples when it reach to define the port it didnt write COM2 or any port insted it write Serial.list()[0] I searched to know why then I learned that this will help to not waste time and look on arduino and see what port I choosed. Instead I can write in processing Serial.list()[0] and processing directly will connect to the port that I connect my PCB to.



So this means that the code is working and here is a problem with my board. So when I tried every thing I thought of changing this line from(SoftwareSerial myserial(0,1) to (SoftwareSerial myserial(1,0)) and it did work.

I will briefly explain the code. In processing, I made two buttons one called OPEN and the other CLOSE and this what these servos will do in the final project. So if I pressed OPEN on the screen the board will receive charecter (a) from the application. If I clicked Close the board will receive charecter (b). In the board, if its receive (b) it will move servo 1 to angle 0 and servo 2 to angle 90 (Note: the reason why there will move to different angles because they are in the oppisate direction this means clockwise for servo1 means counterclockwise for servo2). So then I have two option I can write (if else) and make it waite for the character (a) or I can just write (else). I wrote (else) go to angle 0 for servo 2 and angle 90 for servo 1. To make it easy I will add the pinout fot Atmega328p which I brought it from here.



Here is Arduino code
Here is processing code

My Experience

This week opened for my many doors. I really become excited to learn processing and python more. I learned and found very good books. Regarding processing my advice to everyone want to start learning it is to read the book I provide above also to use the examples from processing. This will clear it for you.

Previous week Home Next week