HI guys,
i m new to the field of electronics and programming,i have this problem where i hv to store the analoginput as an array to use it in processing..the thing is i dunno how to store the constantly changing data from the sensor as an array and how to use the array in processing.plz help.
Moderator edit: Thread title made not all caps. (Nick Gammon)
#include
int i[18]
int pingPin = 13;
int inPin = 12;
void setup() {
}
void loop()
{
// establish variables for duration of the ping,
// and the distance result in inches and centimeters:
long duration, inches, cm;
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
// The same pin is used to read the signal from the PING))): a HIGH
// pulse whose duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(inPin, INPUT);
duration = pulseIn(inPin, HIGH);
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
lcd.print(cm);
lcd.print("cm");
delay(100);
}
long microsecondsToCentimeters(long microseconds)
{
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
return microseconds / 29 / 2;
}
well this is the code i found i wanna know if i can use the following to get an array
Thnx... Apart from the semicolons can you gv me solution to the problem..u hv a valid point that all my arrays will hv the same data what should i do to get the varying data and store em in the different arrays...i hv tried tutorials but doesnt seem to work so plz help.....