Software de Transmissão para Comunicação entre 2 Arduinos por Rádio
Este é o software de transmissão, que utiliza em parte as rotinas desenvolvidas por Maurice Ribble (30/08/2009), disponíveis em http://www.glacialwanderer.com/hobbyrobotics.
/*
Projeto:
Transmissão de dados por RF entre duas placas Arduino
Objetivos:
Experimentar a transmissão de dados por RF entre duas placas Arduino
Experimentar os módulos de transmissão e recepção de RF
Estabelecer os fundamentos para futuras experiências envolvendo controle remoto
Componentes:
2 Placas Arduino Duemilanove com ATmega328
1 módulo transmissor de RF de 315 MHz
1 módulo receptor de RF de 315 MHz
Autor: Karl Heinz Benz
Data: 23/12/2010
Correções, sugestões e nova documentação devem ser enviadas a karlbenz@terra.com.br
Licenciamento: Atribuição-Uso não-comercial-Compartilhamento pela mesma licença 3.0 Brasil
http://creativecommons.org/licenses/by-nc-sa/3.0/br/
Utilização do pacote de software desenvolvido por:
Maurice Ribble
30/08/2009
http://www.glacialwanderer.com/hobbyrobotics
*/
// Módulo de TRANSMISSÃO
#define NETWORK_SIG_SIZE 3
#define VAL_SIZE 2
#define CHECKSUM_SIZE 1
#define PACKET_SIZE (NETWORK_SIG_SIZE + VAL_SIZE + CHECKSUM_SIZE)
// The network address byte and can be change if you want to run different devices in proximity to each other without interfearance
#define NET_ADDR 5
void setup()
{
Serial.begin(1200); // Hardware suporta até 2400, mas 1200 fornece maior alcance.
}
int sensorPin = A0; // Entrada conectada ao pino central do potenciômetro
int sensorValue = 0;
void loop()
{
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
writeUInt(sensorValue); // Put any number you want to send here
delay(100); // Debounce button
}
const byte g_network_sig[NETWORK_SIG_SIZE] = {0x8F, 0xAA, NET_ADDR}; // Few bytes used to initiate a transfer
// Sends a word over the RF network
void writeUInt(word val)
{
byte checksum = (val/256) ^ (val&0xFF);
Serial.write(0xF0); // This gets reciever in sync with transmitter
Serial.write(g_network_sig, NETWORK_SIG_SIZE);
Serial.write((byte*)&val, VAL_SIZE);
Serial.write(checksum); //CHECKSUM_SIZE
}
Projeto:
Transmissão de dados por RF entre duas placas Arduino
Objetivos:
Experimentar a transmissão de dados por RF entre duas placas Arduino
Experimentar os módulos de transmissão e recepção de RF
Estabelecer os fundamentos para futuras experiências envolvendo controle remoto
Componentes:
2 Placas Arduino Duemilanove com ATmega328
1 módulo transmissor de RF de 315 MHz
1 módulo receptor de RF de 315 MHz
Autor: Karl Heinz Benz
Data: 23/12/2010
Correções, sugestões e nova documentação devem ser enviadas a karlbenz@terra.com.br
Licenciamento: Atribuição-Uso não-comercial-Compartilhamento pela mesma licença 3.0 Brasil
http://creativecommons.org/licenses/by-nc-sa/3.0/br/
Utilização do pacote de software desenvolvido por:
Maurice Ribble
30/08/2009
http://www.glacialwanderer.com/hobbyrobotics
*/
// Módulo de TRANSMISSÃO
#define NETWORK_SIG_SIZE 3
#define VAL_SIZE 2
#define CHECKSUM_SIZE 1
#define PACKET_SIZE (NETWORK_SIG_SIZE + VAL_SIZE + CHECKSUM_SIZE)
// The network address byte and can be change if you want to run different devices in proximity to each other without interfearance
#define NET_ADDR 5
void setup()
{
Serial.begin(1200); // Hardware suporta até 2400, mas 1200 fornece maior alcance.
}
int sensorPin = A0; // Entrada conectada ao pino central do potenciômetro
int sensorValue = 0;
void loop()
{
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
writeUInt(sensorValue); // Put any number you want to send here
delay(100); // Debounce button
}
const byte g_network_sig[NETWORK_SIG_SIZE] = {0x8F, 0xAA, NET_ADDR}; // Few bytes used to initiate a transfer
// Sends a word over the RF network
void writeUInt(word val)
{
byte checksum = (val/256) ^ (val&0xFF);
Serial.write(0xF0); // This gets reciever in sync with transmitter
Serial.write(g_network_sig, NETWORK_SIG_SIZE);
Serial.write((byte*)&val, VAL_SIZE);
Serial.write(checksum); //CHECKSUM_SIZE
}
Esse código também roda no Arduino Uno?
ResponderExcluirNão testei, mas deve rodar.
ResponderExcluir