MEMS cvičenie 6
Zo stránky SensorWiki
Oboznámenie so zbernicou i2c
Úlohy:
- Pripojte k procesoru pamäť podľa schémy zapojenia
- Schému upravte tak, aby adresa zariadenia bola ??
- Zapíšte na prvé pamäťové miesto (adresa 0x00) znak 'A'
- Prečítajte, či je znak správne zapísaný
- Prečítajte obsah celej pamäte a vypíšte ho na terminál.
Literatúra
- Official I2C Specification Version 6 http://www.nxp.com/documents/user_manual/UM10204.pdf
- Official List of assigned NXP / Philips I2C addresses http://www.diolan.com/downloads/i2c-address-allocation-table.pdf
- ---
- [ht-ps://www.arduino.cc/en/Reference/Wire Wire Library] Reference
- Serial Library - Print Reference
Datasheets
1. Schéma zapojenia
![](/sensorwiki/images/thumb/4/4b/I2c_schematic.png/400px-I2c_schematic.png)
![](/sensorwiki/images/thumb/1/1e/I2c_breadboard.png/400px-I2c_breadboard.png)
2. Device address
![](/sensorwiki/images/thumb/1/11/I2c_address.png/400px-I2c_address.png)
3. Zápis
![](/sensorwiki/images/thumb/0/08/I2c_write.png/400px-I2c_write.png)
2. Čítanie
![](/sensorwiki/images/thumb/d/d0/I2c_read.png/400px-I2c_read.png)
5. Pomôcka k Serial Print
![](/sensorwiki/images/6/6a/TerminalScreenshot01.png)
void setup()
{
byte c = 78;
Serial.begin(9600);
Serial.print("Hello, World!");
Serial.println("Hello, World!");
Serial.println(78);
Serial.println(c);
Serial.println('c');
Serial.println(1.23456);
Serial.println();
}
void loop()
{
Serial.println("Hello, World!");
}
![](/sensorwiki/images/0/08/TerminalScreenshot02.png)
void setup()
{
byte c = 85; // c = 'U';
Serial.begin(9600);
Serial.println(c);
Serial.println(c, BIN);
Serial.println(c, DEC);
Serial.println(c, HEX);
Serial.println((char)c);
Serial.println();
Serial.println(1.23456, 0);
Serial.println(1.23456, 2);
Serial.println(1.23456, 4);
Serial.println();
Serial.print("Temperature = ");
Serial.print(c);
Serial.print(' ');
Serial.write(176);
Serial.println("C [OK]");
}
void setup()
{
}