Declaring Digital Signal August 12, 2011 11:11AM |
Registered: 13 years ago Posts: 64 |
[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:
#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.