I have a 3D printer (Mendel) with Generation 6 electronics board. Here is the main code for that:
[forums.reprap.org]
I have connected an Arduino to the Gen 6 board and started communication via I2C using this routine. This code goes into the Arduino:
(replace " " with <>
#include "Wire.h"
//i2c address of the gen 6
int REP_RAP_ADDR = 4;
//my address
int CP_ADDR = 5;
void receiveEvent(int howMany)
{
while(0 < Wire.available()) // loop through all
{
char c = Wire.receive(); // receive byte as a character
Serial.print(c); // print the character
}
}
void sendGCode(char* GCode)
{
Wire.beginTransmission(REP_RAP_ADDR);
Wire.send(GCode);
Wire.endTransmission();
}
void setup()
{
Wire.begin(CP_ADDR);
Wire.onReceive(receiveEvent); // register event so that anything received on i2c is sent to the serial
//Test gcode, this should send the machine's X, Y and Z to home
sendGCode("G28 X0 Y0 Z0\n");
}
void loop()
{
}
I2C has already been initialized in the main code.
Now I need a digital signal at say pin 2 of Arduino. I have connected a LED at pin 2 and I want that LED to light up when the printer is printing and off when it is not printing. How to achieve this ??
I am guessing I need to include something in the main code as well as to the code that I have posted for Arduino, but I am not sure what or how
Edited 1 time(s). Last edit at 08/12/2011 11:18AM by Javaid Butt.