Minor Error in Script When Combining Codes?


hello, have project involves solar panel stand moves either using joystick (manual control code) or light sensors (autonomous control code). 2 servo motors used: 1 up-down movement, 1 left-right movement. manual , auto codes work themselves. in combined code, want function when digital pin #2 sees high input, either manual or auto code works, , when sees low, other code works. have button provide either constant high or low. right now, when combined code uploaded, servos flip out, shake, , overall unhappy. also, no functions work, seems if manual code , auto codes fighting each other. i'm pretty sure i'm missing minor, i'm not sure since new arduino , c++.  codes have worked attached correctly. great, thank you.

without looking closely @ code seems mixed up
code: [select]
void manualcontrol() {
  //setup manual control -->(joystick code)
  serial.begin(9600);
  serial.println("starting combined_code.ino");
  (byte n = 0; n < 2; n++) {
    servo[n].attach(servopin[n]);
  }}
void autonomouscontrol() {
  //setup autonomous control --> (light sensor code)
  serial.begin(9600);
  horizontal.attach(9);
  vertical.attach(10);
  horizontal.write(180);
  vertical.write(45);
  delay(3000);
}


you need merge these 2 parts 1 eliminate duplication.

...r


Arduino Forum > Using Arduino > Programming Questions > Minor Error in Script When Combining Codes?


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor