#include <SoftwareSerial.h> #include <EEPROM.h> /*-----( Declare Constants and Pin Numbers )-----*/ #define SSerialRX 10 //Serial Receive pin #define SSerialTX 11 //Serial Transmit pin #define SSerialTxControl 3 //RS485 Direction control #define RS485Transmit HIGH #define RS485Receive LOW #define Pin13LED 13 /*-----( Declare objects )-----*/ SoftwareSerial RS485Serial(SSerialRX, SSerialTX); // RX, TX /*-----( Declare Variables )-----*/ int byteReceived; int byteSend; float f; int eeAddress; byte value; int val = 0; void setup() {//READ SLAVE ID FROM EEPROM// // put your setup code here, to run once: Serial.begin(9600); pinMode(SSerialTxControl, OUTPUT); digitalWrite(SSerialTxControl, RS485Transmit); // Enable RS485 Transmit RS485Serial.write( EEPROM.get(eeAddress,f)); // Send byte to Remote Arduino // delay(10); digitalWrite(SSerialTxControl, RS485Receive); // Disable RS485 Transmit } void loop() { }
#include <EEPROM.h> #include <SoftwareSerial.h> /*-----( Declare Constants and Pin Numbers )-----*/ #define SSerialRX 10 //Serial Receive pin #define SSerialTX 11 //Serial Transmit pin #define SSerialTxControl 3 //RS485 Direction control #define RS485Transmit HIGH #define RS485Receive LOW /*-----( Declare objects )-----*/ SoftwareSerial RS485Serial(SSerialRX, SSerialTX); // RX, TX /*-----( Declare Variables )-----*/ int byteReceived; int byteSend; float f; int eeAddress; byte value; void setup() { // put your setup code here, to run once: Serial.begin(9600); float f = 123.000f; //Variable to store in EEPROM. int eeAddress = 0; //Location we want the data to be put. //One simple call, with the address first and the object second. EEPROM.put(eeAddress, f); pinMode(SSerialTxControl, OUTPUT); RS485Serial.begin(9600); digitalWrite(SSerialTxControl, RS485Receive); // Disable RS485 Transmit if (RS485Serial.available()) //Look for data from other Arduino { byteReceived = RS485Serial.read(); // Read received byte Serial.write(byteReceived); // Show on Serial Monitor delay(10); } } void loop() { // put your main code here, to run repeatedly: }
setup()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)