ES ordening

This commit is contained in:
Rens Pastoor
2025-05-27 23:20:05 +02:00
parent d9244f1ae3
commit 39269a71a7
49 changed files with 1952 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
#include <Arduino.h>
#include <Wire.h>
volatile uint8_t receivedValue = 0;
void setup() {
Wire.begin(0x42);
Wire.onReceive(receiveEvent);
Wire.onRequest(requestEvent);
Serial.begin(9600);
}
void loop() {
}
void receiveEvent(int howMany) {
if (howMany > 0) {
receivedValue = Wire.read();
Serial.print("Received from master: ");
Serial.println(receivedValue);
}
}
void requestEvent() {
uint8_t reply = (receivedValue > 100) ? 2 : 4;
Wire.write(reply);
Serial.print("Sent to master: ");
Serial.println(reply);
}