Pages: 1 [2] 3   Go Down
Author Topic: Interpreting sensor input for robot.  (Read 2124 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry I'm used to programing with visual basic, is this better?
Code:
int incomingByte = 0;
int LeftF= 1;
int RightF= 2;
int LeftB= 3;
int RightB= 4;
const int pingPin = 7;
void setup()
{
  pinMode(RightF,OUTPUT);
  pinMode(LeftF,OUTPUT);
  pinMode(LeftB,OUTPUT);
  pinMode(RightB,OUTPUT);
  Serial.begin(9600);
}

void loop()
{
        if (Serial.available() > 0) {
                incomingByte = Serial.read();

                Serial.print("I received: ");
                Serial.println(incomingByte, DEC);
        }
{
if (incomingByte == 97){
digitalWrite(RightF,HIGH);
digitalWrite(LeftB,HIGH);
}

if (incomingByte == 100){
digitalWrite(LeftF,HIGH);
digitalWrite(RightB,HIGH);
}

if (incomingByte == 119){
digitalWrite(LeftF,HIGH);
digitalWrite(RightF,HIGH);
}

if (incomingByte == 0){
digitalWrite(LeftB,HIGH);
digitalWrite(RightF,HIGH);
}

if (incomingByte == 115){
digitalWrite(LeftB,HIGH);
digitalWrite(RightB,HIGH);
}
}
}
Also for future reference do you know what variable that ultrasonic sensor code was using to output it's value for distance in inches? I'm unsure if I should use the pingPin variable or not.
« Last Edit: March 06, 2014, 09:07:51 pm by Crock101 » Logged

Offline Offline
Sr. Member
****
Karma: 4
Posts: 329
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry I'm used to programing with visual basic, is this better?
yes, it is - but look at where your loop ends; compare it to this http://arduino.cc/en/Serial/Available

have you tried running the code ?
how does your robot behave ?

Also for future reference do you know what variable that ultrasonic sensor code was using to output it's value for distance in inches? I'm unsure if I should use the pingPin variable or not.
that pingPin variable is simply specifying the Arduino pin that it is connected to.
there's no point using it if you don't have the sensor itself.
the code for using that sensor is a whole new ballgame and you've only copied snippets of it which won't do you any good.


EDIT:
use the Auto Format feature ( Ctrl-T ) to tidy up your code and help you see it better.
« Last Edit: March 06, 2014, 09:59:37 pm by retronet_RIMBA1ZO » Logged

Offline Offline
Sr. Member
****
Karma: 4
Posts: 329
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...
...
For some reason it dosn't like this line of code when i try to upload it.
Code:
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);

it says that microsecondsToInches was not declared in the scope and I don't know how it wants me to declare it.
i'm not sure about that one, i'll try it out and get back to you.
okay, i finally figured this one out !  smiley-grin

the error was in the declaration;
Code:
long microsecondsToInches(long microseconds);
{
  return microseconds / 74 / 2;
}
the first semi-colon doesn't belong there !!
(good "refresher course" for me ! smiley-grin )
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok here is my latest code:
Code:
int incomingByte = 0;
int LeftF= 1;
int RightF= 2;
int LeftB= 3;
int RightB= 4;
void setup()
{
  pinMode(RightF,OUTPUT);
  pinMode(LeftF,OUTPUT);
  pinMode(LeftB,OUTPUT);
  pinMode(RightB,OUTPUT);
  Serial.begin(9600);
}

void loop() {
        if (Serial.available() > 0) {
                incomingByte = Serial.read();

                Serial.print("I received: ");
                Serial.println(incomingByte, DEC);
        }
  {
    if (incomingByte == 97){
    digitalWrite(RightF,HIGH);
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftF,LOW);
    }
  }
  {
    if (incomingByte == 100){
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftB,LOW);
    }
  }
  {
    if (incomingByte == 119){
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightF,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftB,LOW);
    }
  }
  {
    if (incomingByte == 0){
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightF,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftF,LOW);
    }
  }
  {
    if (incomingByte == 115){
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftF,LOW);
    }
  }
}
The problem is that the LeftF pin won't go low even though it does when I use this code:
Code:
int LeftF= 1;
int RightF= 2;
int LeftB= 3;
int RightB= 4;

void setup()
{
  pinMode(RightF,OUTPUT);
  pinMode(LeftF,OUTPUT);
  pinMode(LeftB,OUTPUT);
  pinMode(RightB,OUTPUT);
}

void loop() {
    digitalWrite(RightF,HIGH);
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftF,LOW);
    }
Any suggestions?
Logged

Offline Offline
Sr. Member
****
Karma: 4
Posts: 329
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...
...The problem is that the LeftF pin won't go low even though it does when I use this code:
Code:
int LeftF= 1;
int RightF= 2;
int LeftB= 3;
int RightB= 4;

void setup()
{
  pinMode(RightF,OUTPUT);
  pinMode(LeftF,OUTPUT);
  pinMode(LeftB,OUTPUT);
  pinMode(RightB,OUTPUT);
}

void loop() {
    digitalWrite(RightF,HIGH);
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftF,LOW);
    }
Any suggestions?
when won't it go low ?
try adding comments to each line with the ASCII codes - like // press 'w' - move forward, etc.
also there seem to be quite a few unnecessary pairs of curly brackets;
Code:
  {
    if (incomingByte == 97){
    digitalWrite(RightF,HIGH);
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftF,LOW);
    }
  }
you don't really need the first and last ones there, the if statement doesn't need to be enclosed in them.

and did you use the Ctrl-F to auto-format ?
do that and it should look closer to this;
Code:
void loop() {
  if (Serial.available() > 0) {
    incomingByte = Serial.read();

    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
  }

  if (incomingByte == 97){
    digitalWrite(RightF,HIGH);
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftF,LOW);
  }
}
see where they're lined up ?

now look at the loop() code in its simple(pseudo) form;
void loop() {
// check #1
  if (Serial is available) {
    read the keypress and store to variable called incomingByte
  }

// check #2
  if (incomingByte has a value){
    write HIGH/LOW to these pins
  }
}


check #1 and #2 are mutually exclusive, meaning, even if check #1 was NOT true, ie. NO keypressed, check #2 would STILL be performed, because the variable incomingByte DOES have a value (from the previous loop).
Logged

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3077
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So,  the arduino code you posted in the third reply is pretty clear.

The arduino queries the device using standard I2C methods,  and reads six bytes back.    It gets the 6 bytes from one "register" in the device in the dc mode,   and a different series of 6 registers in the ac mode.

I suggest you connect your device, as recommended,  and see what you get.   You should be able to figure it out.

The device has 5 actual vision zones and 9 interpolated vision zones,     it is a bit hard to see how you report the result of that in six bytes (  instead of 5 bytes or 9 bytes ),    but try it,  and see what you get.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I figured out that my pin 1 was just outputting high for no reason, so i switched the LeftF over to pin 5 and it works perfectly now. As for michinyons' reply, I suspect the 6th byte of data is the distance data from the sensor. I'm just going to substitute in the sensor data for keyboard data for the code i have already. Also is there a way i could use some of the library code in my current code to make the arduino only read the direction data in AC mode?

Here is my current code:

Code:
int incomingByte = 0;
int LeftF= 5;
int RightF= 2;
int LeftB= 3;
int RightB= 4;
void setup()
{
  pinMode(RightF,OUTPUT);
  pinMode(LeftF,OUTPUT);
  pinMode(LeftB,OUTPUT);
  pinMode(RightB,OUTPUT);
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() > 0)
  {
    incomingByte = Serial.read();

    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
  }

  if (incomingByte == 97)
  {
    digitalWrite(RightF,HIGH);
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftF,LOW);
  }
  if (incomingByte == 100)
{
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftB,LOW);
  }


  if (incomingByte == 119)
{
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightF,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftB,LOW);
  } 

  if (incomingByte == 115)
{
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftF,LOW);
  }

}
« Last Edit: March 07, 2014, 03:44:06 pm by Crock101 » Logged

Offline Offline
Sr. Member
****
Karma: 4
Posts: 329
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...
...
Here is my current code:

Code:
int incomingByte = 0;
int LeftF= 5;
int RightF= 2;
int LeftB= 3;
int RightB= 4;
void setup()
{
  pinMode(RightF,OUTPUT);
  pinMode(LeftF,OUTPUT);
  pinMode(LeftB,OUTPUT);
  pinMode(RightB,OUTPUT);
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() > 0)
  {
    incomingByte = Serial.read();

    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
  }

  if (incomingByte == 97)
  {
    digitalWrite(RightF,HIGH);
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftF,LOW);
  }
  if (incomingByte == 100)
{
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftB,LOW);
  }


  if (incomingByte == 119)
{
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightF,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftB,LOW);
  } 

  if (incomingByte == 115)
{
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftF,LOW);
  }

}
okay, that looks much clearer now - but it's still the same "check#1" & "check #2" being independent of each other, but if you're happy with how your robot responds to your key-pressing then i suppose it's doing what you want - just one additional note, you don't have a stop command in there do you ?

right then, now we will try to get the data from the sensor to detemine what incomingByte should be, you could rename that variable to something more appropriate.

here's the reference page for using I2C (or TWI) with the Arduino
http://www.arduino.cc/en/Reference/Wire

like Serial.begin() you will also need one with I2C http://arduino.cc/en/Reference/WireBegin
you will need the address of your sensor, if it's not supplied in the datasheet, you can try scanning for it using http://playground.arduino.cc//Main/I2cScanner

you can start with a fresh sketch to just familiarize yourself with using the I2C connection, after which you can then combine it with your code that runs the motors.

here's a good place to start;
http://arduino.cc/en/Reference/WireRead

Good Luck !
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK so I implemented the code like this:
Code:
#include <Wire.h>
int incomingByte = 0;
int LeftF= 5;
int RightF= 2;
int LeftB= 3;
int RightB= 4;
void setup()
{
  pinMode(RightF,OUTPUT);
  pinMode(LeftF,OUTPUT);
  pinMode(LeftB,OUTPUT);
  pinMode(RightB,OUTPUT);
  Wire.begin();
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() > 0)
 
    Wire.requestFrom(2, 6);   

  while(Wire.available())   
  {
    char c = Wire.read();   
    Serial.print(c);         
  }

  if (incomingByte == 97)
  {
    digitalWrite(RightF,HIGH);
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftF,LOW);
  }

  if (incomingByte == 100)
  {
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftB,LOW);
  }


  if (incomingByte == 119)
  {
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightF,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftB,LOW);
  } 

  if (incomingByte == 115)
  {
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftF,LOW);
  }

}
and I'll get the address for the sensor on Monday went it's suppose to arrive. In the mean time could you help me get that parallax ultrasonic sensor code working sense that's what I'm going to be using to detect the distance between me and the robot?
Logged

Offline Offline
Sr. Member
****
Karma: 4
Posts: 329
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK so I implemented the code like this:
Code:
...
...
void loop() {
  if (Serial.available() > 0)
 
    Wire.requestFrom(2, 6);   

  while(Wire.available())   
  {
    char c = Wire.read();   
    Serial.print(c);         
  }
...
...
and I'll get the address for the sensor on Monday went it's suppose to arrive.
you need to stop just copying code and then guessing where you should paste them.

look at the above as pseudo-code again;

  if (there is something on the Serial connection )   // that's the USB connection from Arduino to your computer
 
    request something from the I2C sensor   

  while( I2C ["serial"] connection is available )   
  {
    read the data into var 'c'   
    show me what 'c' is

  }


does that sound like what you want to do ?


In the mean time could you help me get that parallax ultrasonic sensor code working sense that's what I'm going to be using to detect the distance between me and the robot?
http://www.lmgtfy.com/?q=parallax+ultrasonic+sensor+arduino+code
Logged

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3077
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In my opinion,   you need to sort out what the input you are going to get from the sensor is,   before you start worrying to much about the control of your robot.

You seem to think this sensor is going to tell you the distance to the beacon ?   I don't think so.    It is going to tell you want direction the beacon seems to be.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is this better or am I still doing something wrong?
Code:
#include <Wire.h>
const int pingPin = 7;
int LeftF= 5;
int RightF= 2;
int LeftB= 3;
int RightB= 4;
void setup()
{
  pinMode(RightF,OUTPUT);
  pinMode(LeftF,OUTPUT);
  pinMode(LeftB,OUTPUT);
  pinMode(RightB,OUTPUT);
  Wire.begin();
  Serial.begin(9600);
}

void loop() {

  while(Wire.available())   
  {
    Wire.requestFrom(2, 6);
    char c = Wire.read();   
    Serial.print(c);         
  }

  long duration, inches, cm;

  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);

  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
 
  Serial.print(inches);
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();
 
  delay(100);
}

long microsecondsToInches(long microseconds)
{
  return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
  return microseconds / 29 / 2;
}

  if (c == )
  {
    digitalWrite(RightF,HIGH);
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftF,LOW);
  }

  if (c == )
  {
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftB,LOW);
  }


  if (c == ) and (inches > 12)
  {
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightF,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftB,LOW);
  } 

  if (c == ) and (inches < 3)
  {
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftF,LOW);
  }
  if (c == ) and (inches <= 12) and (inches >= 3)
  {
    digitalWrite(LeftB,LOW);
    digitalWrite(RightB,LOW);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftF,LOW);
  }
}
Logged

Offline Offline
Sr. Member
****
Karma: 4
Posts: 329
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is this better or am I still doing something wrong?
Code:
#include <Wire.h>
const int pingPin = 7;
int LeftF= 5;
int RightF= 2;
int LeftB= 3;
int RightB= 4;
void setup()
{
  pinMode(RightF,OUTPUT);
  pinMode(LeftF,OUTPUT);
  pinMode(LeftB,OUTPUT);
  pinMode(RightB,OUTPUT);
  Wire.begin();
  Serial.begin(9600);
}

void loop() {

  while(Wire.available())   
  {
    Wire.requestFrom(2, 6);
    char c = Wire.read();   
    Serial.print(c);         
  }

  long duration, inches, cm;

  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);

  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
 
  Serial.print(inches);
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();
 
  delay(100);
}

long microsecondsToInches(long microseconds)
{
  return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
  return microseconds / 29 / 2;
}

  if (c == )
  {
    digitalWrite(RightF,HIGH);
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftF,LOW);
  }

  if (c == )
  {
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftB,LOW);
  }


  if (c == ) and (inches > 12)
  {
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightF,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftB,LOW);
  } 

  if (c == ) and (inches < 3)
  {
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftF,LOW);
  }
  if (c == ) and (inches <= 12) and (inches >= 3)
  {
    digitalWrite(LeftB,LOW);
    digitalWrite(RightB,LOW);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftF,LOW);
  }
}
still a lot i'm afraid;
aside from the c==<<no value>>;
you need to look up http://arduino.cc/en/Reference/HomePage to find out how to use Boolean Operators.

have you tried to verify that code ?
always use Ctrl-T & Ctrl-R (Shortcut for "Verify" button) to make sure your code is okay - compiler-wise.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Better?
Code:
#include <Wire.h>
const int pingPin = 7;
int LeftF= 5;
int RightF= 2;
int LeftB= 3;
int RightB= 4;
void setup()
{
  pinMode(RightF,OUTPUT);
  pinMode(LeftF,OUTPUT);
  pinMode(LeftB,OUTPUT);
  pinMode(RightB,OUTPUT);
  Wire.begin();
  Serial.begin(9600);
}

void loop()
{
  {
    while(Wire.available())   
    {
      Wire.requestFrom(2, 6);
      char c = Wire.read();   
      Serial.print(c);         
    }

    long duration, inches, cm;

    pinMode(pingPin, OUTPUT);
    digitalWrite(pingPin, LOW);
    delayMicroseconds(2);
    digitalWrite(pingPin, HIGH);
    delayMicroseconds(5);
    digitalWrite(pingPin, LOW);

    pinMode(pingPin, INPUT);
    duration = pulseIn(pingPin, HIGH);

    inches = microsecondsToInches(duration);
    cm = microsecondsToCentimeters(duration);

    Serial.print(inches);
    Serial.print("in, ");
    Serial.print(cm);
    Serial.print("cm");
    Serial.println();

    delay(100);
  }

  long microsecondsToInches(long microseconds)
  {
    return microseconds / 74 / 2;
  }

  long microsecondsToCentimeters(long microseconds)
  {
    return microseconds / 29 / 2;
  }

  if (c == )
  {
    digitalWrite(RightF,HIGH);
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftF,LOW);
  }

  if (c == )
  {
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftB,LOW);
  }


  if (c == ) && (inches > 12)
  {
    digitalWrite(LeftF,HIGH);
    digitalWrite(RightF,HIGH);
    digitalWrite(RightB,LOW);
    digitalWrite(LeftB,LOW);
  } 

  if (c == ) && (inches < 3)
  {
    digitalWrite(LeftB,HIGH);
    digitalWrite(RightB,HIGH);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftF,LOW);
  }
  if (c == ) && (inches <= 12) && (inches >= 3)
  {
    digitalWrite(LeftB,LOW);
    digitalWrite(RightB,LOW);
    digitalWrite(RightF,LOW);
    digitalWrite(LeftF,LOW);
  }
}
Also it says that everything is fine except the fact that I get this error message 'microsecondsToInches' was not declared in this scope but that should go away once I connect the ultrasonic sensor.
Logged

Offline Offline
Sr. Member
****
Karma: 4
Posts: 329
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Better?
not quite, but at least you've fixed the if statements into the loop() now.
is there any reason why you haven't yet filled in the values to compare 'c' with ?


...
...
Also it says that everything is fine except the fact that I get this error message 'microsecondsToInches' was not declared in this scope but that should go away once I connect the ultrasonic sensor.

no, that won't go away even if you connect the sensor;
have a read of this http://arduino.cc/en/Reference/Scope for what scope means and see if you can spot the mistake you still have re: that function (ie. microsecondsToInches)

Logged

Pages: 1 [2] 3   Go Up
Jump to: