// Wire Controller Reader // by Nicholas Zambetti [http://www.zambetti.com](http://www.zambetti.com)
// Demonstrates use of the Wire library // Reads data from an I2C/TWI peripheral device // Refer to the "Wire Peripheral Sender" example for use with this
// Created 29 March 2006
// This example code is in the public domain.
#include<Wire.h>
voidsetup() { Wire.begin(); // join i2c bus (address optional for master) Serial.begin(9600); // start serial for output }
while (Wire.available()) { // peripheral may send less than requested char c = Wire.read(); // receive a byte as character Serial.print(c); // print the character }
int analogPin = A3; // potentiometer wiper (middle terminal) connected to analog pin 3 // outside leads to ground and +5V int val = 0; // variable to store the value read
voidsetup() { Serial.begin(9600); // setup serial }
voidloop() { val = analogRead(analogPin); // read the input pin Serial.println(val); // debug value K}K
/* Globals */ uint16_t analog_val; uint8_t lower_val, upper_val; int y; int time=0;
voidsetup() { Serial.begin(9600); // opens and configures the USB serial port for baudrate 115200 /* This does some magic which is necessary on the Nano Every */ SPI.begin(); /* Enable SPI, put it in Slave mode, set MSB first */ SPI0.CTRLA = (SPI_DORD_bm & (SPI_ENABLE_bm & (~SPI_MASTER_bm))); /* disable "Slave Select Disable" --> to ensure it will stay slave */ SPI0.CTRLB &= ~(SPI_SSD_bm); /* Set Mode 0 (is default though) */ SPI0.CTRLB |= (SPI_MODE_0_gc); SPI0.INTCTRL = SPI_IE_bm; /* SPI Interrupt enable */