Show Posts
Pages: [1] 2
1  Using Arduino / Sensors / Re: Infrared Sensors~Code to make them work? on: November 07, 2012, 04:15:53 pm
Thank you for the link, it is extremely helpful!
2  Using Arduino / Sensors / Infrared Sensors~Code to make them work? on: November 06, 2012, 08:50:48 pm
Hello everyone,

I'm working a project that involves using infrared sensors and infrared beamers, what i'm trying to do is basically I have the beamers and sensors on a mobile robot,I want the beamers to send out an infrared signal so it bounces off nearby surfaces and returns the signal back at the robot for the sensors to pick up.

Now I know very little about the code needed for the sensors to work but what I do know is that I need to set up code so that my Arduino is constantly monitoring the sensors, the part that i'm turning to you, the community, for help, is the part of code that measures how intense the returning signal is and when it is past a certain level because  I want a certain action to execute once it's past that level.

For example, If the intensity of returning beams is level 50+ I want the board to execute a command.

Please keep in mind that i'm a novice programmer and I rely quite heavily on these forums so if you post suggested lines of code to try to keep it simple so its easier for me to understand, that would be great.

Thanks in advance!  smiley
3  Using Arduino / Programming Questions / Re: I don't know whats wrong with my code... on: March 11, 2012, 07:26:59 pm
well guess what? I owe you guys! You helped fix my robot!  smiley-lol i tested it and fixed some of the delay times and it runs PERFECTLY. Special thanks to crossroads. He helped with the major problem.  smiley
4  Using Arduino / Programming Questions / Re: I don't know whats wrong with my code... on: March 11, 2012, 06:38:35 pm
Are you saying this is THE ACTUAL code you run?
yes...why do you ask?
5  Using Arduino / Programming Questions / I don't know whats wrong with my code... on: March 11, 2012, 06:21:40 pm
Hello, i'm working on a project with servo motor's and micro switches and am having a problem with the code, here is the code (ill explain the problem shortly):
Code:
const int Lsencor = 4;
const int Rsencor = 7;
#include <Servo.h>
Servo myservo;
Servo myservo2;
int Lsencorvar = 0;
int Rsencorvar = 0;

void setup()
{
  pinMode (Lsencor, INPUT);
  pinMode (Rsencor, INPUT);
  myservo.attach(5); //Left wheel
  myservo2.attach(6); //Right wheel
}

void forward()
{
  myservo.write(10);
  myservo2.write(180);
}

void turnright()
{
  myservo.write(92);
  myservo2.write(92);
  delay(250);
  myservo.write(180);
  myservo2.write(10);
  delay(500);
  myservo.write(45);
  delay(500);
}
void turnleft()
{
  myservo.write(92);
  myservo2.write(92);
  delay(250);
  myservo.write(180);
  myservo2.write(10);
  delay(500); <--------------------------PROBLEM AREA
  myservo.write(150);
  delay(500);
}

void back()
{
  myservo.write(180);
  myservo2.write(10);
}

void loop()
{
  Lsencorvar = digitalRead (Lsencor);
  Rsencorvar = digitalRead (Rsencor);
  if (Lsencor == HIGH)
  {
    turnright();
  }
  if (Rsencor == HIGH)
  {
    turnleft();
  }
  else
  {
    forward
  }
}

 
if you saw the arrow pointing to the delay then you just looked at my problem. My problem is when i run that part of the code the board resets every time it gets to that delay. any suggestions on how to fix this? PS: feel free to point out anything else you see that might be wrong.
6  Using Arduino / Installation & Troubleshooting / Board reseting in the middle of a program. on: February 21, 2012, 05:54:36 pm
Hello, i'm working on a program and it runs fine except that when it reaches a point in the program the board resets. I don't know why but when that happens the code just restarts from the beginning and ignores the rest until it gets to the same part where it resets and so on, this dosen't happen for every program i write just some of them. This is really getting me down, thanks in advance  smiley-fat
7  Using Arduino / Programming Questions / Re: So i'm programming a robot... on: February 21, 2012, 05:19:35 pm
Thanks for the help everyone  smiley-razz. I noticed a few comments criticizing my code's, well I apologize for my noobish-ness but I am self taught and have had no professional help. Im' really thankful for the advice, but if someone could quote some of the things others posted (that have coding in it) and maybe help me understand by talking about which parts do what. I realize your all important people and have things to do but It would mean a lot! thanks!   smiley-grin
8  Using Arduino / Programming Questions / Re: So i'm programming a robot... on: February 20, 2012, 11:04:38 pm
they are connected from the 5v pin to pins 3 and 2
9  Using Arduino / Programming Questions / So i'm programming a robot... on: February 20, 2012, 08:57:12 pm
Hello, im working on a robot for my local science fair and am having great difficulty programming it so here I am asking for help. First I have a question:
(This involves IF and ELSE statements) If i have a program with 2 different IF statements in it and can have 1 ELSE for them?

To the point smiley-roll-sweat smiley-roll-sweat smiley-roll-sweat smiley-roll-sweat smiley-roll-sweat smiley-roll-sweat smiley-roll-sweat:In my program I have 2 continuous rotation servos and two NC micro switches that act as touch senors for the robot. What i am trying to do is to get the robot go forward untill one of the senors are pressed. When that happens I want the robot to stop, backup, turn, then continue forward. I'm having trouble writing a program for two senors (left and right), can someone please help me with the programming by leaving  some tips or examples in the reply's. Thanks a lot in advance and i really need the help? smiley-sweat

Here's what I have so far if it help's anyone help me:
Quote
const int Lsencor = 2;
const int Rsencor = 3;
#include <Servo.h>
Servo myservo;
Servo myservo2;

void setup()
{
  pinMode (Lsencor, INPUT);
  pinMode (Rsencor, INPUT);
  myservo.attach(10);
  myservo2.attach(6);
}

void loop() {
  //Setup for Lmotor
  digitalRead (Lsencor);

  if (Lsencor == HIGH);
  {
    myservo.write(92);
    myservo2.write(92);
    delay(3000);
    myservo.write(180);
    myservo2.write(10);
    delay(4000);
    myservo2.write(92);
    myservo.write(30);
    delay(2500);
    myservo.write(92);
  }

  //setup for Rmotor
  digitalRead (Rsencor);

  if (Rsencor == HIGH) {
    myservo.write(92);
    myservo2.write(92);
    delay(3000);
    myservo2.write(10);
    myservo.write(180);
    delay(5000);
    myservo.write(92);
    myservo2.write(180);
    delay(2500);
    myservo2.write(92);
  }

  else{
    myservo.write(180);
    myservo2.write(10);
  }
}

10  Using Arduino / Programming Questions / How do i tell my servo to stop? on: February 19, 2012, 02:39:23 pm
Hello, i'm working with continuous rotation servo's and i'm having trouble finding the code to make then stop turning. Here's what I have so far: (This makes the servo's start turning)
Code:
{myservo.write(180);
To make them stop I tried this:
Code:
{myservo.write(LOW);
but that only makes them continue turning, can someone leave some code that would help? thanks!  smiley
11  Using Arduino / Displays / Re: LED's and resistor's... on: February 15, 2012, 07:39:48 pm
LCD's whoops i read too fast i read LED's  smiley-roll-sweat
12  Using Arduino / Displays / LED's and resistor's... on: February 12, 2012, 04:05:39 pm
Hello, iv been working with LED's and have been following the basic rule: When you plug in a LED, you have to have a resistor connected in series. I'm using 1K resistor's and the 5mm LED I have connected barely light's up. When I try without the resistor it lights up as it was intended. I'v heard that the current can damage the board if there is no resistor, is that so and if i'm running only 5 volt's though it will it damage my board? Thanks!
13  Using Arduino / Motors, Mechanics, and Power / Re: Shields for servos on: February 10, 2012, 05:47:57 pm
I'm using two servo's and i'm using the board in the link in my original post.
14  Using Arduino / Motors, Mechanics, and Power / Re: Shields for servos on: February 09, 2012, 01:19:37 pm
Quote
It's important that you not try to supply 5V to the servos using the 5V supply from the Arduino

so in other words you should use the screw pins for GND a Vin nd to power the servo's instead of trying to use the 5V the arduino supports, correct?
15  Using Arduino / Motors, Mechanics, and Power / Re: Shields for servos on: February 08, 2012, 04:34:24 pm
Quote
If you're describing RC servos then no, this is not an appropriate shield.

as i'm new to this i'm not exactly sure what an RC servo is,but if it helps this is the servo i'm using.

here's the link: http://www.sparkfun.com/products/9347
Pages: [1] 2