Loading...
  Show Posts
Pages: 1 ... 41 42 [43] 44 45 ... 103
631  Using Arduino / Project Guidance / Re: Joystick shield help on: February 17, 2013, 10:38:31 pm
Well what I would do is use a joystick and a button. Joystick to move the servo, and the button to lock the position. I would set the button up as a latch, so press it once, it stores the set position, press again clear it.

Add: Or what you can do is, have it so that in order to move the servo, you have to press and hold the button. You let go of the button, and the position stays.
632  Using Arduino / Project Guidance / Re: Beginner Traffic light project on: February 17, 2013, 04:01:28 pm
Code:
void loop(){
 
   void greenLight(){
   digitalWrite(carGreen, HIGH);
   digitalWrite(pedRed, HIGH);
   digitalWrite(carRed, LOW);
   digitalWrite(carYellow, LOW);
   digitalWrite(pedGreen, LOW);
   delay(digitalDelay);
  }
 //===========================================
  void yellowLight(){
   digitalWrite(carYellow, HIGH);
   digitalWrite(pedRed, HIGH);
   digitalWrite(carRed, LOW);
   digitalWrite(carGreen, LOW);
   digitalWrite(pedGreen, LOW);
   delay(5000);
  }
  //==========================================
  void redLight(){
   digitalWrite(carRed, HIGH);
   digitalWrite(pedGreen, HIGH);
   digitalWrite(carGreen, LOW);
   digitalWrite(carYellow, LOW);
   digitalWrite(pedRed, LOW);
   delay(digitalDelay);
  }
}

Close, but function go outside the loop(). What you want to do is call the functions. So it would look like this.

Code:
void loop() {
//timer goes up here and does calls one of the functions when needed.
greenLight();
yellowLight();
redLight();
}

//functions go here
void greenLight(){
   digitalWrite(carGreen, HIGH);
   digitalWrite(pedRed, HIGH);
   digitalWrite(carRed, LOW);
   digitalWrite(carYellow, LOW);
   digitalWrite(pedGreen, LOW);
   delay(digitalDelay);
  }

  void yellowLight(){
   digitalWrite(carYellow, HIGH);
   digitalWrite(pedRed, HIGH);
   digitalWrite(carRed, LOW);
   digitalWrite(carGreen, LOW);
   digitalWrite(pedGreen, LOW);
   delay(5000);
  }

  void redLight(){
   digitalWrite(carRed, HIGH);
   digitalWrite(pedGreen, HIGH);
   digitalWrite(carGreen, LOW);
   digitalWrite(carYellow, LOW);
   digitalWrite(pedRed, LOW);
   delay(digitalDelay);
  }

If it looks like crap, its because I just C & P your stuff and put it together.
633  Using Arduino / Project Guidance / Re: Easy vr simpliest code on: February 17, 2013, 01:36:48 pm
I pretty sure it can be programmed to follow a command in ANY language. What you do is setup a word, and record what that word represents. Everytime the robot hears that particular word, it will do the intended action.
634  Using Arduino / Programming Questions / Re: Program stops after button press on: February 17, 2013, 01:33:26 pm
There was something wrong with my code?, I thought it did EXACTLY what you wanted. You press it once, it increments once, you press and hold it and it increments at the delay(200) rate.

Ok, well if you got it to work on your own, then thats even better. You found the problem and was able fixed it.
635  Using Arduino / Project Guidance / Re: Beginner Traffic light project on: February 17, 2013, 01:22:03 pm
EDIT
Ok, you made a good effort, but there is just TOO much code for some thing that is just too simple.

I want you to take Nick's advice and make your LEDs into functions. When you have done so post your code.
636  Using Arduino / Project Guidance / Re: Arduino project to apply what I have learned in logic design on: February 16, 2013, 06:19:27 pm
The analog pins can be used as digital inputs too.
637  Using Arduino / Project Guidance / Re: Arduino project to apply what I have learned in logic design on: February 16, 2013, 06:14:26 pm
Well if you can get a couple of buttons, then you can make quite a few projects all in one. In fact there are examples provided to you with the Arduino software, that deal with logic gates, latches and Boolean algebra.

Zatara7: 20, what about the analog pins?
638  Using Arduino / Programming Questions / Re: KEYWORDS.TXT on: February 16, 2013, 06:05:29 pm
The function of it use is in the name, KEYWORDS. If you make a library, you need to make a keywords file so the Arduino can recognize what your doing. Every library has one, and without it you may have problems.

Try this, go into the servo library, keywords and take out SERVO, then see if your still able to use that library correctly.
639  Using Arduino / Project Guidance / Re: Arduino project to apply what I have learned in logic design on: February 16, 2013, 06:01:45 pm
Logic gates, latches, flip flops, boolean algebra, no problem. You need to know those anyways to do 99% (not 90)of codes. You are limited to the number of pins available, so you may want to include de/multiplexers, or use an Arduino Mega. (Lots of pins to use).
640  Using Arduino / Project Guidance / Re: Beginner Traffic light project on: February 16, 2013, 05:37:37 pm
Quote
Not for a beginner. digitalWrite is fine.

True, but it will be good to use for future developments.
641  Using Arduino / Programming Questions / Re: Transferring variables from android to arduino on: February 16, 2013, 04:56:11 pm
What happens if you just read in a single char, do you get back that char? The code you posted will NOT work. What you should do is make a set sized array and store the chars each time a new one comes in. So if data is available, update a counter and add the new char to the array. And it may need a null terminator at the end of the array.

To view what you have, use a for loop to display each char in the array.
642  Using Arduino / Project Guidance / Re: bluetooth text message notifier fo hard of hearing on: February 16, 2013, 04:24:25 pm
Was all that one sentence?
Anyways, it would be far easier and hassle free, just to upgrade her phone. I understand what you want to do, but the idea was already implemented in newer phones, just for that reason.

The only way I can see this working, would be to find a way to intercept the call and set an alert that way. I going to guess that the home phone can do it, because it is plug into a device that can see if a call is coming in.
643  Using Arduino / Programming Questions / Re: Transferring variables from android to arduino on: February 16, 2013, 04:20:06 pm
You will need to right a simple splitter code. Using IF/Else statement, read in one char at a time and use some IF statements to look for '<' '>' and ',' . You can use Arrays to store the data and then convert them into integers for you LEDs.

You can take it a step further and incorporate case statements to switch between multiple LEDs.
There already is a sample code provided in the IDE that allows you to enter 3 values and will adjust the LED accordingly.
644  Using Arduino / Project Guidance / Re: bluetooth text message notifier fo hard of hearing on: February 16, 2013, 04:11:14 pm
If she has an Android or iPhone, then there is a setting under accessibility, to have a notifier for those who can't hear the phone. It can vibrate and even use the flash to alert you when you have a call, text and voicemail.

No Arduino required.
645  Using Arduino / Project Guidance / Re: Beginner Traffic light project on: February 16, 2013, 03:48:02 pm
First: please edit this and put it in code tags #.
Second: this is overly complicated for just switching between LEDs. To simplify your code, use case statements, and/or use direct port manipulation. It will cut this code in half, or more.
Pages: 1 ... 41 42 [43] 44 45 ... 103