|
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
|
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. 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.
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|