I believe im having issue with putting libraries together. I have 2 lines of code that works on there own but when I put them together i'm getting the error code that is attached.
Breakdown of code:
I have got one code that has an lcd screen with a rotary encoder that when moved it increases and decreases the counter int and Counter int (void1).
Also a code that moves a stepper motor clockwise and anti clockwise then does some basic switching (void2). Both of these work fine on there own but when I put them in the same library, using different void loops, this error message occurs.
I have done as much research into these errors as I can but still cant get it to work, any suggestions?
Also I have these weird characters come up on my lcd (image attached). I thought it may be a hardware issue but I have checked and double check but it still happens. any advice will be greatly appreciated!
]
#include <LiquidCrystal.h>
#include <Scheduler.h>
#include <Stepper.h>
#define outputA 34 //DT pin
#define outputB 36 //CLK pin
int buttonState = 0;
const int stepsPerRevolution = 2038; // change this to fit the number of steps per revolution or your motor
const int buttonPin = 9;
const int cameraPin = 8;
const int ledPin = 7;
const int relayPin = 6;
int counter = 0;
int Counter = 60;
int aState;
int aLastState;
boolean bcw;
const int rs = 22, en = 24, d4 = 26, d5 = 28, d6 = 30, d7 = 32;
Stepper myStepper(stepsPerRevolution, 13, 12, 11, 10); // initialize the stepper library on pins 8 through 11:
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
Serial.begin(9600);
Scheduler.startLoop(loop1);
Scheduler.startLoop(loop2);
lcd.begin(16,2);
Serial.println("Bearing.");
lcd.setCursor(0,0);
pinMode (outputA,INPUT);
pinMode (outputB,INPUT);
aLastState = digitalRead(outputA); // Reads the initial state of the outputA
Scheduler.startLoop(1);
char rx_byte = 0;
String rx_str = "";
{
myStepper.setSpeed(6); // set the speed at 60 rpm:
pinMode(buttonPin, INPUT);
pinMode(cameraPin, OUTPUT);
pinMode(relayPin, OUTPUT);
pinMode(ledPin, OUTPUT);
}
}
void loop1 () {
{
aState = digitalRead(outputA); // Reads the "current" state of the outputA
// If the previous and the current state of the outputA are different, means knob is rotating
if (aState != aLastState)
{ // If the outputB state is different to the outputA state, that means the encoder is rotating clockwise
if (digitalRead(outputB) != aState)
{
counter ++;
Counter ++;
bcw = true;
}
else
{
bcw = false;
counter --;
Counter --;
}
lcd.setCursor(0,0);
lcd.println("True N");
lcd.setCursor(12,0);
lcd.println(Counter);
lcd.setCursor(0,2);
lcd.println("Relative N");
lcd.setCursor(12,2);
lcd.println(counter);
}
aLastState = aState; // Updates the previous state of the outputA with the current state
}
}
void loop2 () {
buttonState = digitalRead(buttonPin);
digitalWrite(ledPin, HIGH);
if (buttonState == HIGH) {
digitalWrite(ledPin, LOW);
digitalWrite(cameraPin, HIGH);
delay (1000);
Serial.println("clockwise"); // step one revolution in one direction:
myStepper.step(stepsPerRevolution);
digitalWrite(cameraPin, LOW);
delay(1000);
digitalWrite(relayPin, HIGH);
Serial.println("clockwise"); // step one revolution in one direction:
myStepper.step(-stepsPerRevolution);
delay(5000);
digitalWrite(relayPin, LOW);
delay(5000);
}
else {
}
}
/var/folders/l3/_wznvsn559qc05g29b8m1t3r0000gn/T//ccteLxkK.s: Assembler messages:
/var/folders/l3/_wznvsn559qc05g29b8m1t3r0000gn/T//ccteLxkK.s:1946: Error: constant value required
lto-wrapper: fatal error: /private/var/folders/l3/_wznvsn559qc05g29b8m1t3r0000gn/T/AppTranslocation/263289C8-3DA5-4DC9-8047-ACF4D0EDD5F7/d/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-gcc returned 1 exit status
compilation terminated.
Multiple libraries were found for "LiquidCrystal.h"
Used: /private/var/folders/l3/_wznvsn559qc05g29b8m1t3r0000gn/T/AppTranslocation/263289C8-3DA5-4DC9-8047-ACF4D0EDD5F7/d/Arduino.app/Contents/Java/libraries/LiquidCrystal
Multiple libraries were found for "Scheduler.h"
Used: /Users/Mattstamp/Documents/Arduino/libraries/Scheduler
Multiple libraries were found for "Stepper.h"
Used: /private/var/folders/l3/_wznvsn559qc05g29b8m1t3r0000gn/T/AppTranslocation/263289C8-3DA5-4DC9-8047-ACF4D0EDD5F7/d/Arduino.app/Contents/Java/libraries/Stepper
/private/var/folders/l3/_wznvsn559qc05g29b8m1t3r0000gn/T/AppTranslocation/263289C8-3DA5-4DC9-8047-ACF4D0EDD5F7/d/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Mega ADK.