how to use sensor(arduino) to control some images in Processing

edited August 2017 in Arduino

Hi all, I am curently working for one installation with Arduino and Processing. In general, there will be 4 sensors to detecting the movement of ppl in this project. These sensors will be located in the 4 corners of one image. Once one sensor detect someone's movement, we will immediately see that one image transforme into another one. The others sensors work in the same way. And the image will be changed all the time once one sensor catch one movement.

The main problem for me is writing the programe with Processing. (I hope that the animation like some circles turn to a pack of molecule.) But the transformation must be happened when the sensor catch something. I guess that the problem probably is the communication between Arduino and processing.

I am totally a beginner of the language java. I have already tried to find some online tutorials, but i can't find any one because the most of transformations happened with our mouse.

So i am here for looking for help. Anyone knows how to transform one image into another accroding to the movement of ppl specially with arduino? Or anyone can give me some advices ou idee?

Thanks a lot !!!

PS : i use infrared proximity sensor (Sharp GP2Y0A02YK0F)G

Tagged:

Answers

  • Answer ✓

    These next posts can be useful for you:

    https://forum.processing.org/two/discussion/comment/85556/#Comment_85556

    https://forum.processing.org/two/discussion/comment/88886#Comment_88886 (check Feb 27)

    https://forum.processing.org/two/discussion/comment/88115/#Comment_88115

    Previous posts that might be relevant:

    https://forum.processing.org/two/search?Search=proximity

    Now, I have to say it is not clear what you want to do. Here:

    These sensors will be located in the 4 corners of one image

    Do you mean that the sensors are located in four different corners in a room and they will affect each corner in your sketch? Can you clarify this as it is a very important detail.

    I guess that the problem probably is the communication between Arduino and processing.

    I will strongly suggest to work on a simple demo where you work with your ardunio and one sensor + processing. The concept here is for you to become comfortable working with processing, to make sure your arduino+processing communication is working and that you understand your sensor. This program is also very important so you can test any of your sensors to make sure each of them works and that they all behave similarly as dictated by specs. For example, if you are either 20 or 50 cm in front of the sensor, do all sensors output the same value?

    What code do you have so far?

    Kf

  • Thanks so much for your information !!!

  • edited August 2017

    This is one part of my code Arduino

       #include <SharpIR.h>
    
      // declarations les variables 
    
        int analogPin1 = A0;   // choose the input pin for IR sensor    
        int relayPin1 = 8;     // inputPin for Relay   
    
        int val = 0;           // variable for reading the pin status
    
        int pirState1 = LOW;    // we start, assuming no motion detected
        int code_capteur1 = 1;   // code of IR sensor for communicating with Processing
    
      void setup() {
        Serial.begin(9600);
        pinMode(relayPin1, OUTPUT);
        digitalWrite(relayPin1, LOW);
    
      }
    
      void loop() {                   //declaration des variables liees aus IR sensors
        gestion_IR_sensor(analogPin1, pirState1, relayPin1, code_capteur1);
      }
    
      void gestion_IR_sensor ( int analogPin, int etat_capteur, int numero_pin_relay, int code_capteur) {               //int numero_pin_capteur, 
        int valeur; 
        int valeuri = analogRead(analogPin);     // read input value
        if (valeuri > 150) {
          valeur = 1;
        }
        else{
          valeur = 0;
        }
    
        Serial.print(code_capteur);             //send code state of IR sensor
        Serial.println(valeur);               
    
        if (valeur == HIGH) {                    //check if the input is HIGH
          digitalWrite(numero_pin_relay, HIGH);  // turn relay On
          delay(2500);                              // delay 2500milleseconds
          if (etat_capteur == LOW) {
            etat_capteur == HIGH;
          }
        } else {
          digitalWrite(numero_pin_relay, LOW);    // turn relay OFF
          delay(300);
          if (etat_capteur == HIGH){
            etat_capteur == LOW;
            }  
        }
      }
    
Sign In or Register to comment.