Week_12 - Interface and Application Programming

Group Assignment

Below you will find some options related to the group assigments:
  • Processing
  • Ardublock, Tinkercad Circuts
  • MIT App Inventor

    1. Processing is a very interesting programming language that refers very much to Wire used in Arduino IDE. The main feature of this solution is the simplicity of creating visual objects using code. Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology. There are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning and prototyping.
    More about this language in my task.

    2. another way to integrate electronics with a computer can be tinkercad and ardublock. Unfortunately the latter has long ceased to be supported. In this case, our work on the code is done with blocks. So you don't have to know how to code to write even quite complicated programs. Anyway, Piotr Bejenka tells an interesting story about it on one of the webinars we did during the Crownavirus Pandemic. This way is very often used to learn how to code and design electronics with kids. Thanks to the built-in simulator we can conduct workshops even without the use of electronics, so that even kids who cannot afford electronic sets can start their adventure with arduino.



    3rd example is MIT APP INVENTOR I'm not as familiar with this program as I am with the previous ones but it's worth paying attention to this program because of the ability to easily create applications on the phone. Especially if we want to practice some functionality of our project which connects via bluetooth with the phone.

    Prcoessing and Arduino where to start

    This week's task was to integrate the circuit boards with interface programs on the computer. My first choice was the idea to connect something to the app inventor, but I came across a super tutorial about combining processing and electronics and I knew that this is all the more so as I've been trying to learn processing for some time. Unfortunately, a week is not enough to fully learn the new language and start using it fluently (I know what I'm saying for a month I'm learning Spanish and No hablo bien espaƱol).... But thanks to the super tutorials from Mr. Shiffman I managed to get to know the basics of Processing in a few days and thanks to the tutorial on sparkfun , I connected arduino to Processing in order to integrate it all together.

    Few words about Processing


    Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology. There are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning and prototyping.

    From arduino to Processing

    Due to the difficult access to the studio, I decided to use my arduino to connect with processing, i.e. to integrate soft hardware.

    I decided to make a proximity sensor, which when something comes close to the sensor, the object in the processing on the computer monitor will grow bigger.

    What I will need
  • Arduino code detecting distance from sensor
  • code in processing that will increase the circle due to the increasing value of distance
  • arduino
  • Ultrasonic distance sensor HC-SR04
  • wires

    Code in arduino



    			
    				#define trigPin 12
    				#define echoPin 11
    
    				void setup() {
    				  Serial.begin (9600);
    				  pinMode(trigPin, OUTPUT); //Pin, Trig as output
    				  pinMode(echoPin, INPUT); //Echo as input
    				}
    
    				void loop() {
    				  long Time, Distance;
    
    				  digitalWrite(trigPin, LOW);
    				  delayMicroseconds(2);
    				  digitalWrite(trigPin, HIGH);
    				  delayMicroseconds(10);
    				  digitalWrite(trigPin, LOW);
    
    				  Time = pulseIn(echoPin, HIGH);
    				  Distance = Time / 58; // 58 is the number in datasheet its the time it takes for the sound to move by 1 cm
    
    				  Serial.print(Distance);
    				  Serial.println(" cm");
    
    				  delay(500);
    				}
    
    


    Processing Code



    Its good to start with code which writing your Serials

    	
    		// Example by Tom Igoe
    
    import processing.serial.*;
    
    Serial myPort;  // The serial port
    
    void setup() {
      // List all the available serial ports
      printArray(Serial.list());
      // Open the port you are using at the rate you want:
      myPort = new Serial(this, Serial.list()[0], 9600);
    }
    
    void draw() {
      while (myPort.available() > 0) {
        int inByte = myPort.read();
        println(inByte);
      }
    }
    
    
    	
    		import processing.serial.*;
    		Serial myPort;  // Create object from Serial class
    		float val;     // Data received from the serial port
    
    
    
    		void setup()
    		{
    		  // I know that the first port in the serial list on my mac
    		  // is Serial.list()[0].
    		  // On Windows machines, this generally opens COM1.
    		  // Open whatever port is the one you're using.
    		  String portName = Serial.list()[7]; //change the 0 to a 1 or 2 etc. to match your port
    		  myPort = new Serial(this, portName, 9600);
    		  //fullScreen();
    		  size(500,500);
    		}
    		void draw()
    		{
    		  background(0);
    		  if ( myPort.available() > 0)
    		  {  // If data is available,
    		    val = myPort.read();         // read it and store it in val
    		  }
    		  println(val);
    		  stroke(255, 0, 0);
    		  fill(255);
    		  ellipse(width/2, height/2, val+1, val+1);
    
    
    		  delay(500);
    		}
    
    
    

    all files from projects