Hi, sorry if i have chosen the wrong category, I have 2 boards connected in parallel both with an LCD connected, my master board can read and write the temperature to the LCD connected but i cant seem to receive the code on the other board is anyone able to help, the boards i am using are the Mega 2560
Master Code:
#include <LiquidCrystal.h>
#include <arduino.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#define DHTPIN 13
#define DHTTYPE DHT22
byte i = 0;
int intpin = 44;
int rcv_ready = 45;
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
DHT dht(DHTPIN, DHTTYPE);
void setup(){
DDRA = B11111111; //Output
DDRC = B11111111; //Output
pinMode(intpin, OUTPUT);
pinMode(rcv_ready, INPUT);
lcd.begin(16, 2);
lcd.print("Temperature and");
lcd.setCursor(0, 1);
lcd.print("Humidity ! ");
Serial.begin(9600);
Serial.println("Humidity and Temperature:");
delay(700);
}
void loop() {
lcd.setCursor(0, 0);
lcd.clear();
float t = dht.readTemperature(true, false);
float h = dht.readHumidity(); // Remove the 'true' argument
float t2 = dht.convertFtoC(t);
lcd.print("temp.: ");
lcd.print(t2);
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("Humi.: ");
lcd.print(h);
lcd.print(" %");
Serial.print("Current humidity = ");
Serial.print(h);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(t2); Serial.println("C ");
transmit();
delay(800);
}
void transmit(){
PORTA = temp;
PORTC = hum;
lcd.setCursor(0,1);
lcd.print("Humi: ");
lcd.print(hum);
while(rcv_ready==LOW){}
digitalWrite(intpin, LOW);
lcd.setCursor(0,0);
lcd.print("temp: ");
lcd.print(temp);
delay(299);
}
Slave Code;
#include <LiquidCrystal.h>
#include <Wire.h>
#include <Arduino.h>
byte x = 0;
byte y = 0;
int rcv_ready = 45;
void setup(){
DDRA = B00000000; //Input
DDRC = B00000000; //Input
Serial.begin(19200);
attachInterrupt(5, blink, RISING);
pinMode(rcv_ready, OUTPUT);
digitalWrite(rcv_ready, LOW);
}
void loop()
{
}
void blink(){
x = PINA;
y = PINC;
delay(100);
digitalWrite(rcv_ready, HIGH);
delay(100);
digitalWrite(rcv_ready, LOW);
Serial.print(x);
Serial.print(" , ");
Serial.println(y);
}
I know i dont have much on the second board but i cant seem to figure it out so i have left it very basic, My Temperature sensor is the DHT22 and the signal pin is connected to Digital 13, any other questions you may need to help me please ask.
1 post - 1 participant