Cannot read Data from sensors correctly, and it always automatically INPUT Data. I used Piezo sensor put into Analog(A0), it will automatically input Data, even I do not touch it!
I tried many methods to solve this problem, such as changing coding or circuit. However, these are all not helpful!
Do you think Arduino Uno are broken or my setting problem! But I think I still follow the right way to do it, and before it worked!
What I want is when PIEZO SENSOR is touched, a circle in screen will be changed its size. It worked before, but now cannot work!
import ddf.minim.*;//declare
AudioPlayer player;//upload Musi
Minim minim;////upload 5 Music based on sensor1-5
import org.firmata.*;
import cc.arduino.*;
import processing.serial.*;
Arduino arduino;
int buttonPin = 13;
int sensorPin1 = 0;
int sensorPin2 = 1;
int sensorPin3 = 2;
int sensorPin4 = 3;
int sensorPin5 = 4;
int sensorLevel = 500;
void setup() {
size(1028, 720);
smooth();
noStroke();
ellipseMode(CENTER);
arduino = new Arduino(this, Arduino.list()[4], 57600);
arduino.pinMode(buttonPin, Arduino.OUTPUT);
arduino.pinMode(sensorPin1, Arduino.INPUT);
}
void draw()
{
int analogValue = arduino.analogRead(sensorPin1);
println(analogValue); //print it for testing purposes
if (analogValue>sensorLevel) {
background(400, 200, 500);
stroke(247,142,142);
strokeWeight(15);
//fill(255, analogValue, analogValue);
ellipse(width/2, height/2, analogValue-100, analogValue-100);
arduino.digitalWrite(buttonPin, Arduino.HIGH);
//minim=new Minim(this);//
//player=minim.loadFile("mo.mp3");//locate file
//player.play();
} else {
arduino.digitalWrite(buttonPin, Arduino.LOW);
}
}