forked from JoaquimFlavio/GuaraTeca_Hardware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-atualização dos examples do MPU6050 -criação dos examples do PCF8574 (leitura e escrite) -criação do metodo de leitura PCF8574
- Loading branch information
1 parent
11c792c
commit 3016184
Showing
7 changed files
with
136 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Guarateca_Hardware *** by *** Guarabots___________ | ||
* | ||
* [CI: PCF8574 e semelhantes] | ||
* | ||
* Utilização das funçoes de manipulação do registrador | ||
* de deslocamento (PCF8574). | ||
* | ||
* !!!!Conectar nas portas I2C do micro-controlador | ||
* | ||
* Autor: Joaquim Flávio A Q Gomes___________________ | ||
* Data: 09/2018_____________________________________ | ||
*/ | ||
|
||
//Inclusão da biblioteca. | ||
#include <GuaraTeca_Hardware.h> | ||
//Inclusão da biblioteca para I2C. | ||
#include <Wire.h> | ||
|
||
//Declaramos o objeto e definimos seu endereço. | ||
PCF8574 expansor(0x3F); | ||
|
||
void setup() { | ||
//Inicialização do monitor Serial em 9600. | ||
Serial.begin(9600); | ||
//Inicializamos a biblioteca para I2C. | ||
Wire.begin(); | ||
} | ||
|
||
void loop() { | ||
/* | ||
* Utilizamos o metodo "estadoPino(pino, endereço)" para | ||
* alterar o estado do pino: HIGH/LOW. | ||
*/ | ||
for(int i=0;i<8;i++){ | ||
expansor.estadoPino(i, HIGH); | ||
delay(500); | ||
expansor.estadoPino(i, LOW); | ||
delay(500); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Guarateca_Hardware *** by *** Guarabots___________ | ||
* | ||
* [CI: PCF8574 e semelhantes] | ||
* | ||
* Utilização das funçoes de manipulação do registrador | ||
* de deslocamento (PCF8574). | ||
* | ||
* !!!!Conectar nas portas I2C do micro-controlador | ||
* | ||
* Autor: Joaquim Flávio A Q Gomes___________________ | ||
* Data: 09/2018_____________________________________ | ||
*/ | ||
|
||
//Inclusão da biblioteca. | ||
#include <GuaraTeca_Hardware.h> | ||
//Inclusão da biblioteca para I2C. | ||
#include <Wire.h> | ||
|
||
//Declaramos o objeto e definimos seu endereço. | ||
PCF8574 expansor(0x3F); | ||
|
||
void setup() { | ||
//Inicialização do monitor Serial em 9600. | ||
Serial.begin(9600); | ||
//Inicializamos a biblioteca para I2C. | ||
Wire.begin(); | ||
/* | ||
* Utilizamos o metodo "leitura(void)" para realizar a | ||
* leitura do estado de todos os pinos. | ||
* Esse metodo retorna um byte com todos os pinos lidos. | ||
*/ | ||
Serial.println(expansor.leitura(), BIN); | ||
/* | ||
* O metodo "leitura(void)" tambem armazena o estado dos | ||
* pino de forma individual, em um vetor do tipo "bool" | ||
* cada posição deste vetor representa necessariamente o | ||
* pino lido. ex: a leitura do pino 0 sera armazenada em | ||
* "expansor.porta[0]". | ||
*/ | ||
for(int i=0;i<8;i++){ | ||
Serial.println(expansor.porta[i]?"HIGH":"LOW"); | ||
} | ||
} | ||
|
||
void loop() { | ||
expansor.leitura(); | ||
Serial.println("Leitura dos pinos: "); | ||
for(int i=0;i<8;i++){ | ||
Serial.println(expansor.porta[i]?"HIGH":"LOW"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters