void receiveEvent(int howMany)
{
}
void requestEvent()
{
Wire.send("start");
}
Serial.begin(HOST_BAUD);
Serial.println("start");
Wire.begin(4);
Wire.onReceive(receiveEvent); // register event
Wire.onRequest(requestEvent); // register event
#define I2CMODE 1
#define SERIALMODE 0
int inputMode = SERIALMODE;
#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()
{
}
[COLOR="#008000"]int pin = 13;
volatile int state = LOW;
[/COLOR]
[COLOR="#0000FF"]void setup()
{
pinMode(pin, OUTPUT);
attachInterrupt(0, blink, CHANGE);
}[/COLOR]
void loop()
{
digitalWrite(pin, state);
}
[COLOR="#FF0000"]void blink()
{
state = !state;
}[/COLOR]
int pbIn = 0; // Interrupt 0 is on DIGITAL PIN 2!
int ledOut = 4; // The output LED pin
volatile int state = LOW; // The input state toggle
void setup()
{
// Set up the digital pin 2 to an Interrupt and Pin 4 to an Output
pinMode(ledOut, OUTPUT);
//Attach the interrupt to the input pin and monitor for ANY Change
attachInterrupt(pbIn, stateChange, CHANGE);
}
void loop()
{
//Simulate a long running process or complex task
for (int i = 0; i < 100; i++)
{
// do nothing but waste some time
delay(10);
}
}
void stateChange()
{
state = !state;
digitalWrite(ledOut, state);
}
So the only connection between the Gen 6 and the Arduino is the I2C bus correct?
And yeah, I am not receiving any notifications at all from here :shock:
And yeah, I am not receiving any notifications at all from here
#include <Wire.h>
#include "SPI.h" // necessary library
int del=2.5; // used for various delays
word outputValue = 0; // a word is a 16-bit number
byte data = 0; // and a byte is an 8-bit number
int ledPin = 4; // LED connected to digital pin 2
int B = ledPin;
//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 requestEvent()
{
Wire.beginTransmission(CP_ADDR);
Wire.send("javaid");
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");
pinMode(B, OUTPUT); // sets the digital pin as output
//set pin(s) to input and output
pinMode(10, OUTPUT);
SPI.begin(); // wake up the SPI bus.
SPI.setBitOrder(MSBFIRST);
}
void loop()
{
{
while (digitalRead(B)){ //read LED
if (B = 1) // if the value is 1
digitalWrite(B, HIGH); // sets the LED on
else
digitalWrite(B, LOW); // sets the LED off
}
}
int A;
for (int A=0; A<=4095; A++)
{
outputValue = A;
digitalWrite(10, LOW);
data = highByte(outputValue);
data = 0b00001111 & data;
data = 0b00110000 | data;
SPI.transfer(data);
data = lowByte(outputValue);
SPI.transfer(data);
digitalWrite(10, HIGH);
delay(del);
}
delay(del+25);
for (int A=4095; A>=0; --A)
{
outputValue = A;
digitalWrite(10, LOW);
data = highByte(outputValue);
data = 0b00001111 & data;
data = 0b00110000 | data;
SPI.transfer(data);
data = lowByte(outputValue);
SPI.transfer(data);
digitalWrite(10, HIGH);
delay(del);
}
delay(del+25);
}
#include <Wire.h>
#define reprap 6
#define slave 5
void setup ()
{
Wire.begin (reprap);
}
void loop()
{
Wire.beginTransmission (slave);
Wire.send ("G1");
Wire.endTransmission();
Wire.beginTransmission (slave);
Wire.send ("G28");
Wire.endTransmission();
}
#include <Wire.h>
#define slave 5
#define LED 13
void receiveEvent (int howMany)
{
char buf [10];
byte i = 0;
while (Wire.available () > 0)
{
char c = Wire.receive ();
if (i < sizeof (buf) - 1) // check for overflow
buf [i++] = c;
} // end of while
buf [i] = 0; // terminating null
if (memcmp (buf, "G1", 2) == 0)
digitalWrite (LED, HIGH);
else if (memcmp (buf, "G28", 3) == 0)
digitalWrite (LED, LOW);
} // end of receiveEvent
void setup ()
{
Wire.begin (slave);
Wire.onReceive (receiveEvent);
pinMode (LED, OUTPUT);
} // end of setup
void loop()
{
// nothing in main loop
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?