safwan092

Untitled

May 3rd, 2024
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <Wire.h>
  2.  
  3. #define PICO_ADDRESS 0x10
  4.  
  5. void setup() {
  6. Wire.begin(PICO_ADDRESS); // Initialize I2C as slave
  7. Wire.onReceive(receiveEvent); // Register receive event
  8. Serial.begin(9600); // Initialize serial communication
  9. }
  10.  
  11. void loop() {
  12. // Do something in the loop if needed
  13. }
  14.  
  15. void receiveEvent(int numBytes) {
  16. while (Wire.available() > 0) {
  17. // Read received data byte by byte
  18. char receivedByte = Wire.read();
  19. Serial.println(receivedByte);
  20. }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment