BigW Consortium Gitlab

Commit a50e2be3 by Forest Godfrey
parents 80d952e3 b410d813
#include <Wire.h>
#define INTERRUPT_PIN 9
#define I2C_ADDRESS 0x42
unsigned long next_send_intr;
int current_intr_val;
void i2cReceive(int bytes) {
Serial.print("Bytes available: ");
Serial.println(bytes);
while (1 < Wire.available()) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
}
void setup() {
// Initialize console
Serial.begin(9600);
Serial.println("Arduino I2C Keyboard Driver Built " __DATE__ " " __TIME__);
// Initialize Interrupt Pin
digitalWrite(INTERRUPT_PIN, 1);
pinMode(INTERRUPT_PIN, OUTPUT);
// Initialize I2C Slave Interface
Wire.begin(I2C_ADDRESS); // join i2c bus with address #8
Wire.onReceive(i2cReceive);
next_send_intr = 0;
current_intr_val = 1;
}
void loop() {
// put your main code here, to run repeatedly:
if (millis() > next_send_intr) {
current_intr_val = current_intr_val ? 0 : 1;
digitalWrite(INTERRUPT_PIN, current_intr_val);
next_send_intr = millis() + 5000;
Serial.print("Interupt pin now ");
Serial.println(current_intr_val);
}
delay(10);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment