Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: problem with microsecondsToInches on: September 29, 2013, 09:30:44 pm
hi.
it was a spelling mistake is working.
 but a problem with the lcd connection i am going to look at the lcd in the next few days
2  Using Arduino / Programming Questions / problem with microsecondsToInches on: September 29, 2013, 08:34:47 pm
Hi
i am having an issue with the following program
i keep getting an error
ping_servo_buzzer.ino:53: error 'microsecondsToInches was not declared in this scope'
i have tried many things but still look at the code below to see what i have done wrong.

thanks
chilliman

code:

#include <Servo.h> // include the servo library
#include <LiquidCrystal.h> // include lcd library

Servo servoMotor; // creates an instance of servo object to control a servo
LiquidCrystal lcd(12,11,6,5,4,3);// int the lcd library

const int pingPin = 10; // control pin for ping sensor
const int servoPin = 8; // control pin for servo motor
const int speakerPin =9; // control pin for speaker

int moveServoLeft =0;
int moveServoRight =0;
   
void setup()
{
  // setup the lcd 's # of rows and columns
  lcd.begin(16,2);
  // initial display
  lcd.setCursor(0,0);
  lcd.print("Distance(inch)");
  lcd.setCursor(0,0);
 
  servoMotor.attach(servoPin); // attach the servo on pin 8
  servoMotor.write(0); // set servo to intial position
 
  moveServoLeft = 1; // int motion of servo is from 0 to 180
 
   
             }
           
   void loop(){

     //get distance long
     long duration, inches, cm;
     // set speaker pin a nd servo to output
     pinMode(speakerPin,LOW);
     pinMode(servoPin, OUTPUT);
     digitalWrite(speakerPin,LOW); //sound buzzer is defalut switched off
     
     //ping sensor is two pulse high
     pinMode(pingPin, OUTPUT);
     digitalWrite(pingPin,LOW);
     delayMicroseconds(2);
     digitalWrite(pingPin, HIGH);
     delayMicroseconds(5);
     digitalWrite(pingPin, LOW);
     // more ping sensor
     pinMode(pingPin,INPUT);
     duration = pulseIn(pingPin, HIGH);
     
     // convert the time into a distance
     
   inches = microsecondsToInches(duration);
   cm = microsecondsToCentimeters(duration);
   
     
       delay(200);
       lcd.clear();
       //set cursor to col 0, line 1
       lcd.print("Distance (inch)");
       lcd.setCursor(0,1);
       lcd.print(inches):
    // to enable tracking servo
       if(inches >=5){
         servoMotor.attach(servoPin);
         servoMotor.write(servoPosition);
         delay(20);
    // to move right if the motor has reached 180 deg
   
        if(servoPosition == 180 && moveServoLeft ==1){
          moveServoRight = 1;
          moveServoLeft =0;
        }
    // to move left if the motor has reached 0 degress
        if(servoPosition == 0 && moveServoRight == 1){
        moveServoLeft =1;
        moveServoRight = 0;
   
        }
    //move left from0 to 180

        if(moveServoLeft == 1 & moveServo<= 160)
            servoPosition = servoPosition + 20;
     //move right from 180 to 0

        if(moveServoRight == 1 & servoPosition >=0)
            servoPosition = servoPosition-20;
       }
    // to disable trace of objrct is lesser that 5"king to servo motor is detached if the distance
   
      else{
        servoMotor.detach();
        for(int duration =0 ; duration <100; duration ++){
          digitalWrite(speakerPin,HIGH);
          delayMicroseconds(200);
          digitalWrite(speakerPin, LOW);
          delayMicroseconds(200);
        }
      }
   }
   
   long mircosecondsToInches(long microseconds)
   {
     return microseconds / 74 /2;
   }
   long mircosecondsToCentimeters(long microseconds)
   {
     return microseconds /29/2;
   }
   /code:

3  Using Arduino / Programming Questions / Re: the best way to set multlple input and outputs on: March 31, 2013, 09:23:27 pm
thanks
4  Using Arduino / Programming Questions / Re: the best way to set multlple input and outputs on: March 31, 2013, 07:38:18 am
Thanks all for the tips ,i shall remember them, is there a right way to add multiple input and out that you what to happen at the same time i.e . what order etc.

thanks chilliman
 smiley
5  Using Arduino / Programming Questions / Re: the best way to set multlple input and outputs on: March 30, 2013, 09:06:31 pm
thanks guys u will check it out over the next few day.
those curly brackets are going to drive me crazy i through i had them right

thanks chilliman smiley
   
6  Using Arduino / Programming Questions / Re: the best way to set multlple input and outputs on: March 30, 2013, 03:56:38 pm
sorry about the code i have changed it now could you please look at it

thanks

chilliman
7  Using Arduino / Programming Questions / the best way to set multlple input and outputs on: March 30, 2013, 07:35:25 am
hi.
i am trying to run ping, lcd and servo , i am not sure which is the best way and order to have the ping, lcd and servo in the program the way i have it right now is as follows:( i am a newbie)
Code:
// include the library code:
#include <LiquidCrystal.h>
#include <Servo.h>
#define trigPin 2
#define echoPin 3

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(10, 11, 12, 13, 14, 15, 16);

Servo myservo;  // create servo object to control a servo                
int pos = 0;    // variable to store the servo position

void setup() {
  {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  
}

void loop()
{
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}


{  long duration, distance;
  lcd.setCursor(0, 1);
  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(102); // Added this line
  digitalWrite(trigPin, HIGH);

  delayMicroseconds(1000); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1* 10;
  
    lcd.print(distance);
    lcd.print(" mm");
    delay(500);
lcd.clear();
}
the arduino seems to be unable to move the servo and the lcd goes blank (power issue ?) or a programming issue any help would appreciated.

thanks Chilliman smiley-sad
8  Using Arduino / Sensors / Re: Temp sensors on: February 06, 2013, 09:08:17 pm
thanks very helpful

chilli man smiley
9  Using Arduino / Sensors / Temp sensors on: February 06, 2013, 07:43:25 pm
Hi.
Has any one used a TMP36GT9 Low Voltage Temperature Sensors  with arduino is there any special i need to do to use this sensor.


thanks chilliman 
10  Using Arduino / Networking, Protocols, and Devices / Re: Raspberry Pi to Arduino usb port issue on: September 30, 2012, 06:04:40 pm
Thanks for the info, i had the IDE to see the broad and one port ( dev/tty/USB0) but when i try and write to board from the Pi nothing happens but i am using 2 USB ports on the PI but the arduino only shows one ?

chilliman
11  Using Arduino / Networking, Protocols, and Devices / Re: Raspberry Pi to Arduino usb port issue on: September 29, 2012, 02:52:57 pm
hi guys.
do you know if this can be done ? or do you need more info from me maybe i did not explain very well please advise.

thank chilliman
12  Using Arduino / Networking, Protocols, and Devices / Raspberry Pi to Arduino usb port issue on: September 25, 2012, 08:14:25 pm
hi.
i am trying to connect a Raspberry Pi to a Arduino Duemilanove started Graphic interfaces selected the correct board selected the only USB port ( dev/tty/USB0) this the only port listed but i using both ports on the Raspberry Pi, but this is not talking to the board  i get the error message on the ardunio ( Connection timed out, programmer is not responding) and the indicators lights TX and RX are not flashing.
  any ideas i am a real newie on Linux any help would be greatly welcome.

Thanks
Chilliman
13  Using Arduino / Interfacing w/ Software on the Computer / Re: taking to web pages on: February 05, 2012, 07:40:48 pm
sorry i did not make it clear what i needed the labscript software is just what  i wanted.
Thanks
chillman
14  Using Arduino / Interfacing w/ Software on the Computer / taking to web pages on: February 04, 2012, 08:35:46 pm
Hi .
i am looking for information on sending or pulling data from arduino to a webpage which is on another web server, is there a good webpage i can go too. to find what code i need to get the data from arduino any help would be greatly appreciated,

chilliman
15  Using Arduino / Programming Questions / Re: just started and having problems on: December 30, 2011, 07:49:09 pm
thanks
for the info , noticed that pin 8 was to control the lcd , i changed it to pin 9 it works ok now just need another set of eyes.

thank chilliman
Pages: [1] 2 3