Hi All,
I am currently using the Uno R3 and the Protoneer Arduino CNC Shield V3.51 (more info here) running GRBL v0.9j to control two stepper motors. I want to use the RGB LCD Shield to allow the user to select a program to run. Without the RGB LCD Shield I am able to run GRBL fine from my PC using UniversalGcodeSender v1.0.9. I wanted to test whether or not the RGB LCD Shield would work with the CNC Shield, so I took the code from the "grblUpload" file:
#include <grbl.h>
and inserted it into the "HelloWorld" file from the Adafruit RGB LCD Shield Library:
/*********************
Example code for the Adafruit RGB Character LCD Shield and Library
This code displays text on the shield, and also reads the buttons on the keypad.
When a button is pressed, the backlight changes color.
**********************/
// include the library code:
#include <Wire.h>
#include <Adafruit_RGBLCDShield.h>
#include <utility/Adafruit_MCP23017.h>
#include <grbl.h>
// The shield uses the I2C SCL and SDA pins. On classic Arduinos
// this is Analog 4 and 5 so you can't use those for analogRead() anymore
// However, you can connect other I2C sensors to the I2C bus and share
// the I2C bus.
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
// These #defines make it easy to set the backlight color
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
void setup() {
// Debugging output
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD. We track how long it takes since
// this library has been optimized a bit and we're proud of it :)
int time = millis();
lcd.print("Hello, world!");
time = millis() - time;
Serial.print("Took "); Serial.print(time); Serial.println(" ms");
lcd.setBacklight(WHITE);
}
uint8_t i=0;
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
uint8_t buttons = lcd.readButtons();
if (buttons) {
lcd.clear();
lcd.setCursor(0,0);
if (buttons & BUTTON_UP) {
lcd.print("UP ");
lcd.setBacklight(RED);
}
if (buttons & BUTTON_DOWN) {
lcd.print("DOWN ");
lcd.setBacklight(YELLOW);
}
if (buttons & BUTTON_LEFT) {
lcd.print("LEFT ");
lcd.setBacklight(GREEN);
}
if (buttons & BUTTON_RIGHT) {
lcd.print("RIGHT ");
lcd.setBacklight(TEAL);
}
if (buttons & BUTTON_SELECT) {
lcd.print("SELECT ");
lcd.setBacklight(VIOLET);
}
}
}
and tried to compile. Compiling failed with the following errors:
C:\Users\FLYNNCON\AppData\Local\Temp\buildd7e3f0dc760fe3f51e3a0b303e4b09c2.tmp/core\core.a(wiring.c.o): In function `__vector_16':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/wiring.c:47: multiple definition of `__vector_16'
libraries\GRBL\stepper.c.o:C:\Users\FLYNNCON\Documents\Arduino\libraries\GRBL/stepper.c:416: first defined here
C:\Users\FLYNNCON\AppData\Local\Temp\buildd7e3f0dc760fe3f51e3a0b303e4b09c2.tmp/core\core.a(HardwareSerial0.cpp.o): In function `__vector_18':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial0.cpp:48: multiple definition of `__vector_18'
libraries\GRBL\serial.c.o:C:\Users\FLYNNCON\Documents\Arduino\libraries\GRBL/serial.c:160: first defined here
C:\Users\FLYNNCON\AppData\Local\Temp\buildd7e3f0dc760fe3f51e3a0b303e4b09c2.tmp/core\core.a(HardwareSerial0.cpp.o): In function `__vector_18':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial0.cpp:48: multiple definition of `__vector_19'
libraries\GRBL\serial.c.o:C:\Users\FLYNNCON\Documents\Arduino\libraries\GRBL/serial.c:42: first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.
with #include <grbl.h>
commented out the program compiles fine.
I'm wondering if it is possible to use the RGB LCD Shield with the CNC Shield and GRBL? If so, what approach should I take?
Appreciate the help.