Operácie

MEMS cvičenie 6: Rozdiel medzi revíziami

Z SensorWiki

d (Schéma zapojenia)
(1. Schéma zapojenia)
Riadok 29: Riadok 29:
  
 
[[Súbor:i2c_breadboard.png|400px|center]]
 
[[Súbor:i2c_breadboard.png|400px|center]]
 +
 +
=== 2. Device address ===
 +
 +
[[Súbor:i2c_address.png|400px|center]]
 +
 +
=== 3. Zápis ===
 +
 +
[[Súbor:i2c_write.png|400px|center]]
 +
 +
=== 2. Čítanie ===
 +
 +
[[Súbor:i2c_read.png|400px|center]]
  
 
=== Pomôcka k Serial Print ===
 
=== Pomôcka k Serial Print ===

Verzia zo dňa a času 10:02, 2. apríl 2016

Oboznámenie so zbernicou i2c

Úlohy:

  1. Pripojte k procesoru pamäť podľa schémy zapojenia
  2. Schému upravte tak, aby adresa zariadenia bola ??
  3. Zapíšte na prvé pamäťové miesto (adresa 0x00) znak 'A'
  4. Prečítajte, či je znak správne zapísaný
  5. Prečítajte obsah celej pamäte a vypíšte ho na terminál.

Literatúra

Datasheets


1. Schéma zapojenia

I2c schematic.png
I2c breadboard.png

2. Device address

I2c address.png

3. Zápis

I2c write.png

2. Čítanie

I2c read.png

Pomôcka k Serial Print

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!");
}


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()
{
}

Návrat na zoznam cvičení...