Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Arduino read 24AA02E48 (I2C MAC)
- // NETESTOVANO !!!
- #define I2C_ADDRESS 0x50
- #include <Wire.h>
- static uint8_t mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- void setup() {
- Wire.begin(); // join i2c bus (address optional for master)
- Serial.begin(9600); // start serial for output
- mac[0] = readRegister(0xFA);
- mac[1] = readRegister(0xFB);
- mac[2] = readRegister(0xFC);
- mac[3] = readRegister(0xFD);
- mac[4] = readRegister(0xFE);
- mac[5] = readRegister(0xFF);
- }
- void loop() {
- }
- byte readRegister(byte r) {
- unsigned char v;
- Wire.beginTransmission(I2C_ADDRESS);
- Wire.write(r); // register to read
- Wire.endTransmission();
- Wire.requestFrom(I2C_ADDRESS, 1); // read a byte
- while (!Wire.available()) {
- // waiting
- }
- v = Wire.read();
- return v;
- }
Advertisement
Add Comment
Please, Sign In to add comment