Reputation: 31
I am trying to made this project and using an Arduino library in Processing (Firmata) for serial communication. For this project, it requires a pull-up resistor, which Arduino analog pins also have, and need to be enabled with code. While I tried a lot of times it's still not working. I am wondering, is the Arduino library on processing capable for enable pull-up resistor? Has anyone done that before?
My sensor is connected to 5v on one end, and on the other is ground and A0.
I uploaded standardFirmata to Arduino. Here is my processing code:
import cc.arduino.*;
import org.firmata.*;
import processing.serial.*;
Arduino arduino;
int A1;
int A2;
void setup() {
size(800, 500);
arduino = new Arduino(this, Arduino.list()[1], 57600);
arduino.pinMode(A1, Arduino.INPUT_PULLUP);
arduino.pinMode(A2, Arduino.INPUT_PULLUP);
}
void draw() {
background(255);
stroke(0);
if ((arduino.analogRead(A1) != 0) {
rect(150, 100, 100, 300);
fill(#BFA4E5);
}
if (arduino.analogRead(A2) != 0) {
rect(250, 100, 100, 300);
fill(#BFA4E5);
}
}
Upvotes: 0
Views: 536
Reputation: 181
You could enable your pull-up resistor with:
pinMode(pin, INPUT);
digitalWrite(pin, HIGH);
Upvotes: 0