MEMS cvičenie 6: Rozdiel medzi revíziami
Z SensorWiki
(→Oboznámenie so zbernicou i2c) |
|||
Riadok 27: | Riadok 27: | ||
[[Súbor:TerminalScreenshot01.png|right]] | [[Súbor:TerminalScreenshot01.png|right]] | ||
− | < | + | <source lang="c++"> |
void setup() | void setup() | ||
{ | { | ||
Riadok 49: | Riadok 49: | ||
} | } | ||
+ | [[Súbor:TerminalScreenshot02.png|right]] | ||
+ | <source lang="c++"> | ||
− | </ | + | </source> |
+ | 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() | ||
+ | { | ||
+ | } | ||
+ | |||
+ | </source> | ||
+ | |||
+ | [[MEMS inteligentné senzory a aktuátory#Cvi.C4.8Denia|Návrat na zoznam cvičení...]] | ||
− | [[ | + | [[Category:MEMS]] |
Verzia zo dňa a času 10:32, 1. apríl 2016
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
Pomôcka k Serial Print
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!");
}
[[Súbor:TerminalScreenshot02.png|right]]
<source lang="c++">
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() { }
</source>