How to make a digital inpur work in firmata (using ping ultrasonic sensor&arduino)
in
Integration and Hardware
•
2 years ago
Hi,
I'm trying to make this sketch move by a digital input from ping))) ultrasonic sensor. No response from the sensor, like dead.
Signal plugged into pin=7
I used this simple sketch (from Processing) and firmata
It used to be "mouseX", instead of "arduino.digitalRead(7)" (I want to use the ping sensor instead of mouseX).
Basically I want to make digital input work (analog-potentiometer etc. works fine).
What am I doing wrong?
Is firmata declared wrongly or digital commands aren't correct?
Thanks!!
M
I'm trying to make this sketch move by a digital input from ping))) ultrasonic sensor. No response from the sensor, like dead.
Signal plugged into pin=7
I used this simple sketch (from Processing) and firmata
- * Mouse 2D.
*
* Moving the mouse changes the position and size of each box.
*/
import processing.serial.*; // reference the serial library
import cc.arduino.*; // reference the arduino library
Arduino arduino;
void setup()
{
size(200, 200);
noStroke();
rectMode(CENTER);
println(Serial.list()); // List all the available serial ports:
arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(7, Arduino.INPUT);
}
void draw()
{
background(51);
fill(255, 204);
rect(arduino.digitalRead(7), height/2, mouseY/2+10, mouseY/2+10);
fill(255, 204);
int inverseX = width-arduino.digitalRead(7);
int inverseY = height-mouseY;
rect(inverseX, height/2, (inverseY/2)+10, (inverseY/2)+10); - }
It used to be "mouseX", instead of "arduino.digitalRead(7)" (I want to use the ping sensor instead of mouseX).
Basically I want to make digital input work (analog-potentiometer etc. works fine).
What am I doing wrong?
Is firmata declared wrongly or digital commands aren't correct?
Thanks!!
M
1