Hi Tom I yes I have written the code all at once, have tried to do it in stages but no luck,
The code is for the Arduino Mega AT 2560 to controll two linear actuators for solar tracker,using relays and LDR
I hope this will come out, so you can understand what I'm trying to do.
Look forward to hear from you.
Kind regards botvid.
I still got error, digitalWrite was not declared in this scope.``
[code]
int powerPin = 3;
int ledPin = 13;
int motoraPin = 40;
int motorlPin = 41;
int motorrPin = 42;
int motorzPin = 50;
int motoruPin = 51;
int motordPin = 52;
int upSunPin = 2;
int downSunPin = 3;
int leftSunPin = 4;
int rightSunPin = 5;
void setup() {
// Serial.begin(9600);
pinMode(motoraPin, OUTPUT);
pinMode(motorlPin, OUTPUT);
pinMode(motorrPin, OUTPUT);
pinMode( motorzPin, OUTPUT);
pinMode( motoruPin, OUTPUT);
pinMode( motordPin, OUTPUT);
delay(3000);
}
void loop() {
// Int vall = analogRead(leftSunPin);
int valr = analogRead(rightSunPin);
int valu = analogRead(upSunPin);
int vald = analogRead(downSunPin);
int scaleLeft = map(vald, 0, 1023, 0, 10);
int scaleRight = map(valr, 0, 1023, 0, 10);
int scaleUp = map(valu, 0, 1023, 0, 15);
int scaleDown = map(vald, 0, 1023, 0, 15);
//Serial.print(vall);
Serial.print("-");
Serial.print(scaleLeft);
Serial.print("LEFT,");
//Serial.print(valr);
Serial.print("-");
Serial.print(scaleRight);
Serial.print("RIGHT;");
//Serial.print(valu);
Serial.print("-");
Serial.print(scaleUp);
Serial.print("UP;");
//Serial.print(vald);
Serial.print("-");
Serial.print(scaleDown);
Serial.println("DOWN.");
if ( scaleLeft == scaleRight) digitalWrite ( motoraPin, LOW);
else digitalWrite ( motoraPin, HIGH);
if (scaleLeft < scaleRight) digitalWrite( motorrPin, HIGH);
else digitalWrite ( motorrPin, LOW);
if (scaleLeft > scaleRight) digitalWrire ( motorlPin, HIGH);
else digitalWrite ( motorlPin, LOW);
if (scaleUp == scaleDown) digitalWrite ( motorzPin, LOW);
else digitalWrite ( motorzPin, HIGH);
if (scaleUp > scaleDown) digitalWrite ( motoruPin, HIGH);
else digitalWrite (motoruPin, LOW);
if ( scaleUp < scaleDown) digitalWrite ( motordPin, HIGH);
else digitalWrite (motordPin, LOW);
delay(100);
}
[/code]Arduino: 1.8.16 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Users\bosse\Documents\Arduino\BareMinimum\BareMinimum.ino: In function 'void loop()':
BareMinimum:73:33: error: 'digitalWrire' was not declared in this scope
if (scaleLeft > scaleRight) digitalWrire ( motorlPin, HIGH);
^~~~~~~~~~~~
C:\Users\bosse\Documents\Arduino\BareMinimum\BareMinimum.ino:73:33: note: suggested alternative: 'digitalWrite'
if (scaleLeft > scaleRight) digitalWrire ( motorlPin, HIGH);
^~~~~~~~~~~~
digitalWrite
exit status 1
'digitalWrire' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Arduino: 1.8.16 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Users\bosse\Documents\Arduino\BareMinimum\BareMinimum.ino: In function 'void loop()':
BareMinimum:73:33: error: 'digitalWrire' was not declared in this scope
if (scaleLeft > scaleRight) digitalWrire ( motorlPin, HIGH);
^~~~~~~~~~~~
C:\Users\bosse\Documents\Arduino\BareMinimum\BareMinimum.ino:73:33: note: suggested alternative: 'digitalWrite'
if (scaleLeft > scaleRight) digitalWrire ( motorlPin, HIGH);
^~~~~~~~~~~~
digitalWrite
exit status 1
'digitalWrire' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
type or paste code here


