Show Posts
|
|
Pages: 1 2 3 [4] 5 6 ... 14
|
|
46
|
Products / Arduino Esplora / Joystick on Esplora help
|
on: March 01, 2013, 05:37:05 am
|
How do I write code so that when I push the joystick up and left at about 45 degrees, the robot turns left forward? Push the joystick up and right at about 45 degrees, the robot turns right forward. Push the joystick down and right at about 45 degrees, the robot turns right backward. Push the joystick down and left at about 45 degrees, the robot turns left backward. if (joystick is up and joystick is left at about 45 degrees) { robot turns left forward } if (joystick is up and joystick is right at about 45 degrees) { robot turns right forward } if (joystick is down and joystick is left at about 45 degrees) { robot turns left backward } if (joystick is down and joystick is right at about 45 degrees) { robot turns right backward }
|
|
|
|
|
47
|
Using Arduino / Programming Questions / Esplora setup loop problem?
|
on: February 28, 2013, 09:08:29 pm
|
I'm trying to write code that lets me use Esplora board to control a robot. When I start the code, it is supposed to set up the servos to center position but nothing happens until I press the joystick button. How can I fix the problem? #include <Esplora.h> int walkflag; void setup() { Serial1.begin(115200); if (Serial1.available()) { robotstand01; < nothing happens here delay(500); } } void loop() { if(Esplora.readJoystickButton()==LOW) { walkflag = 0; robotstand01(); < it works. } if(Esplora.readButton(JOYSTICK_UP)==LOW) { walkflag = 1; robotwalk01(); robotwalk02(); robotwalk03(); robotwalk04(); robotwalk05(); robotwalk06(); robotwalk07(); robotwalk08(); robotwalk09(); } //if(Esplora.readButton(JOYSTICK_DOWN)==LOW) //{ //robotwalk01(); //delay(1000); //robotwalk02(); //delay(1000); //robotwalk03(); //delay(1000); //robotwalk04(); //delay(1000); //robotwalk05(); //delay(1000); //robotwalk06(); //delay(1000); //} } void robotstand01() { Serial1.print("#0 P1500 T500 \r "); Serial1.print("#1 P1500 T500 \r "); Serial1.print("#2 P1500 T500 \r "); Serial1.print("#4 P1500 T500 \r "); Serial1.print("#5 P1500 T500 \r "); Serial1.print("#6 P1500 T500 \r "); Serial1.print("#8 P1500 T500 \r "); Serial1.print("#9 P1500 T500 \r "); Serial1.print("#10 P1500 T500 \r "); Serial1.print("#16 P1500 T500 \r "); Serial1.print("#17 P1500 T500 \r "); Serial1.print("#18 P1500 T500 \r "); Serial1.print("#20 P1500 T500 \r "); Serial1.print("#21 P1500 T500 \r "); Serial1.print("#22 P1500 T500 \r "); Serial1.print("#24 P1500 T500 \r "); Serial1.print("#25 P1500 T500 \r "); Serial1.print("#26 P1500 T500 \r "); delay(500); } void robotwalk01() { Serial1.print("#0 P1500 T500 \r "); Serial1.print("#1 P1667 T500 \r "); Serial1.print("#2 P1667 T500 \r "); Serial1.print("#4 P1500 T500 \r "); Serial1.print("#5 P1500 T500 \r "); Serial1.print("#6 P1500 T500 \r "); Serial1.print("#8 P1500 T500 \r "); Serial1.print("#9 P1667 T500 \r "); Serial1.print("#10 P1667 T500 \r "); Serial1.print("#16 P1500 T500 \r "); Serial1.print("#17 P1500 T500 \r "); Serial1.print("#18 P1500 T500 \r "); Serial1.print("#20 P1500 T500 \r "); Serial1.print("#21 P1667 T500 \r "); Serial1.print("#22 P1667 T500 \r "); Serial1.print("#24 P1500 T500 \r "); Serial1.print("#25 P1500 T500 \r "); Serial1.print("#26 P1500 T500 \r "); delay(500); } <rest of code>
|
|
|
|
|
48
|
Using Arduino / Programming Questions / Execute subroutine/function once?
|
on: February 19, 2013, 08:50:37 pm
|
#include <Esplora.h> int standwalk = 0; void setup() { Serial1.begin(9600); robotstand01(); } void loop() { if(Esplora.readButton(JOYSTICK_UP)==LOW) { //robotstandtowalk01(); //delay(1000); robotwalk01(); delay(1000); robotwalk02(); delay(1000); robotwalk03(); delay(1000); robotwalk04(); delay(1000); robotwalk05(); delay(1000); robotwalk06(); delay(1000); } if(Esplora.readButton(JOYSTICK_DOWN)==LOW) { robotwalk01(); delay(1000); robotwalk02(); delay(1000); robotwalk03(); delay(1000); robotwalk04(); delay(1000); robotwalk05(); delay(1000); robotwalk06(); delay(1000); } } void move(int servo, int position, int time) { Serial1.print("#"); Serial1.print(servo); Serial1.print(" P"); Serial1.print(position); Serial1.print(" T"); Serial1.println(time); } void robotstand01() { move(0,1500,1000); move(1,1500,1000); move(2,1500,1000); move(3,1500,1000); move(4,1500,1000); move(5,1500,1000); move(16,1500,1000); move(17,1500,1000); move(18,1500,1000); move(19,1500,1000); move(20,1500,1000); move(21,1500,1000); } void robotstandtowalk01() { move(0,1500,1000); move(1,1667,1000); move(2,1500,1000); move(3,1500,1000); move(4,1500,1000); move(5,1667,1000); move(16,1500,1000); move(17,1500,1000); move(18,1500,1000); move(19,1667,1000); move(20,1500,1000); move(21,1500,1000); }
void robotwalk01() { move(0,1167,1000); move(1,1667,1000); move(2,1833,1000); move(3,1500,1000); move(4,1167,1000); move(5,1667,1000); move(16,1167,1000); move(17,1500,1000); move(18,1833,1000); move(19,1667,1000); move(20,1167,1000); move(21,1500,1000); } void robotwalk02() { move(0,1167,1000); move(1,1500,1000); move(2,1833,1000); move(3,1500,1000); move(4,1167,1000); move(5,1500,1000); move(16,1167,1000); move(17,1500,1000); move(18,1833,1000); move(19,1500,1000); move(20,1167,1000); move(21,1500,1000); } void robotwalk03() { move(0,1167,1000); move(1,1500,1000); move(2,1833,1000); move(3,1667,1000); move(4,1167,1000); move(5,1500,1000); move(16,1167,1000); move(17,1667,1000); move(18,1833,1000); move(19,1500,1000); move(20,1167,1000); move(21,1667,1000); } void robotwalk04() { move(0,1833,1000); move(1,1500,1000); move(2,1167,1000); move(3,1667,1000); move(4,1833,1000); move(5,1500,1000); move(16,1833,1000); move(17,1667,1000); move(18,1167,1000); move(19,1500,1000); move(20,1833,1000); move(21,1667,1000); } void robotwalk05() { move(0,1833,1000); move(1,1500,1000); move(2,1167,1000); move(3,1500,1000); move(4,1833,1000); move(5,1500,1000); move(16,1833,1000); move(17,1500,1000); move(18,1167,1000); move(19,1500,1000); move(20,1833,1000); move(21,1500,1000); } void robotwalk06() { move(0,1833,1000); move(1,1667,1000); move(2,1167,1000); move(3,1500,1000); move(4,1833,1000); move(5,1667,1000); move(16,1833,1000); move(17,1500,1000); move(18,1167,1000); move(19,1667,1000); move(20,1833,1000); move(21,1500,1000); }
How do I have robotstandtowalk01() subroutine/function execute once? Is it possible to use the code in BlinkWithoutDelay sketch instead of Delay(1000)?
|
|
|
|
|
49
|
Using Arduino / Programming Questions / Arduino Esplora and Lynxmotion SSC-32 help
|
on: February 18, 2013, 03:59:55 pm
|
I connected Arduino Esplora to SSC-32 board made by Lynxmotion. I can use the thumbstick to move my robot. I think that there's a problem with the Arduino code. If I comment out the else parts of the code, the robot walks correctly. If I don't comment out the else parts of the code, there is a slight pause in the walking movement. How can I fix the problem? #include <Esplora.h> void setup() { Serial1.begin(9600); robotstand01(); } void loop() { if(Esplora.readButton(JOYSTICK_UP)==LOW) { robotwalk01(); delay(1000); robotwalk02(); delay(1000); robotwalk03(); delay(1000); robotwalk04(); delay(1000); robotwalk05(); delay(1000); robotwalk06(); delay(1000); } //else //{ // robotstand01(); // delay(1000); //} //delay(50); if(Esplora.readButton(JOYSTICK_DOWN)==LOW) { robotwalk01(); delay(1000); robotwalk02(); delay(1000); robotwalk03(); delay(1000); robotwalk04(); delay(1000); robotwalk05(); delay(1000); robotwalk06(); delay(1000); } //else //{ // robotstand01(); // delay(1000); //} //delay(50); if(Esplora.readButton(JOYSTICK_UP)==LOW || Esplora.readButton(JOYSTICK_DOWN)==LOW) { robotstand01(); delay(1000); } } void move(int servo, int position, int time) { Serial1.print("#"); Serial1.print(servo); Serial1.print(" P"); Serial1.print(position); Serial1.print(" T"); Serial1.println(time); } void robotstand01() { move(0,1500,1000); move(1,1500,1000); move(2,1500,1000); move(3,1500,1000); move(4,1500,1000); move(5,1500,1000); move(16,1500,1000); move(17,1500,1000); move(18,1500,1000); move(19,1500,1000); move(20,1500,1000); move(21,1500,1000); } void robotwalk01() { move(0,1167,1000); move(1,1667,1000); move(2,1833,1000); move(3,1500,1000); move(4,1167,1000); move(5,1667,1000); move(16,1167,1000); move(17,1500,1000); move(18,1833,1000); move(19,1667,1000); move(20,1167,1000); move(21,1500,1000); } void robotwalk02() { move(0,1167,1000); move(1,1500,1000); move(2,1833,1000); move(3,1500,1000); move(4,1167,1000); move(5,1500,1000); move(16,1167,1000); move(17,1500,1000); move(18,1833,1000); move(19,1500,1000); move(20,1167,1000); move(21,1500,1000); } void robotwalk03() { move(0,1167,1000); move(1,1500,1000); move(2,1833,1000); move(3,1667,1000); move(4,1167,1000); move(5,1500,1000); move(16,1167,1000); move(17,1667,1000); move(18,1833,1000); move(19,1500,1000); move(20,1167,1000); move(21,1667,1000); } void robotwalk04() { move(0,1833,1000); move(1,1500,1000); move(2,1167,1000); move(3,1667,1000); move(4,1833,1000); move(5,1500,1000); move(16,1833,1000); move(17,1667,1000); move(18,1167,1000); move(19,1500,1000); move(20,1833,1000); move(21,1667,1000); } void robotwalk05() { move(0,1833,1000); move(1,1500,1000); move(2,1167,1000); move(3,1500,1000); move(4,1833,1000); move(5,1500,1000); move(16,1833,1000); move(17,1500,1000); move(18,1167,1000); move(19,1500,1000); move(20,1833,1000); move(21,1500,1000); } void robotwalk06() { move(0,1833,1000); move(1,1667,1000); move(2,1167,1000); move(3,1500,1000); move(4,1833,1000); move(5,1667,1000); move(16,1833,1000); move(17,1500,1000); move(18,1167,1000); move(19,1667,1000); move(20,1833,1000); move(21,1500,1000); }
|
|
|
|
|
53
|
Using Arduino / Project Guidance / Re: Will this setup cause a fire?
|
on: February 06, 2013, 05:43:29 am
|
|
David82, I think that you should STOP trying to do something that may cause injury or death, and may cause damage to property. You CAN'T try to run 120VAC current through Cat5 cables. If you don't believe me, connect two thin wires to a powerful battery (battery pack for R/C cars). Touch the wires together and watch the insulation melt.
|
|
|
|
|
55
|
Using Arduino / Programming Questions / Re: Arduino Joystick Coding
|
on: February 05, 2013, 09:08:19 pm
|
|
stevekap25, Does the go-cart have pedals for throttle and brakes? If so, you can add a "joystick" connected to the pedals. The linkages between the "joystick" and pedals would be made so that when the client pushes the "joystick" forward, the linkage would push the throttle pedal forward, making the go-cart run. When the client pulls the "joystick" backward, the linkage would push the brake pedal forward, stopping the go-cart. The linkage would have sliding joints so that one pedal is pushed forward at a time.
|
|
|
|
|