Go Down

Topic: Help me display with arduino mega (Read 92 times) previous topic - next topic

rao2_it

Hello,
I ask for help because I can not get out of a problem :
I have an Arduino Mega with most of the ports occupied by an additional shield .
I remain open its doors from 31 to 51 and I want to connect the classic 2x16 display Arduino kit to provide two pieces of information .
I have set the display on a circuit board apart with potentiometer and variable resistance , tested all on one Arduino with the following pins LiquidCrystal LCD ( 12 , 11 , 5 , 4 , 3 , 2 ) ; and it works. I would now like to change the pin and connect it to what I would be free of Arduino Mega . But I only get squares LCD ( 39 , 40 , 41 , 42 , 433 , 38 ) .
I ask for help .
Thank you

Nick_Pyner

Most liquid crystal libraries allow you to call the pins in the programme. The order you call them is vital, and relates to the LCD connections.

So

 * LCD RS pin to digital pin 12                 or 39
 * LCD Enable pin to digital pin 11            or 40
 * LCD D4 pin to digital pin 5                   or 41
 * LCD D5 pin to digital pin 4                  or 42
 * LCD D6 pin to digital pin 3                  or 43
 * LCD D7 pin to digital pin 2                  or 38

and you call    LiquidCrystal lcd(39, 40, 41,42,43,38);
I only mention this as a check and I think you already know what this is about. So I think you are on the right track, and you should check for some silly connection problem. These pins are on the end bank and you could hardly be using them for other purposes by mistake.

rao2_it


The 433 is my typo , sorry . But also replacing the display does not work properly pin

Nick_Pyner

I understand the typo, that's no problem. I'm afraid I don't understand why you display doesn't work, and I'm inclined to suspect the connections. I always have my 16x2 LCD on pin A2 instead of pin 4, and it is just a matter of substituting the numbers in the call.

DO you call the pins in your programme? You had better publish the code.

rao2_it

#include <LiquidCrystal.h>
#include "EmonLib.h"             // Include Emon Library
EnergyMonitor emon1;             // Create an instance
LiquidCrystal lcd(43, 42, 41, 40, 39, 38);



void setup()

 lcd.begin(16, 2);
 lcd.print("hello, world!");
 
  Serial.begin(9600);
 
  emon1.voltage(2, 234.26, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon1.current(1, 111.1);       // Current: input pin, calibration.
  pinMode(31, OUTPUT);
  pinMode(32, OUTPUT);
  pinMode(33, OUTPUT);
  pinMode(34, OUTPUT);
  pinMode(35, OUTPUT);
  pinMode(36, OUTPUT);
  pinMode(37, OUTPUT);
  pinMode(30, OUTPUT);
}

void loop()
{
  emon1.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
   emon1.serialprint();         // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
 
  float realPower       = emon1.realPower;        //extract Real Power into variable
   
 

lcd.setCursor(0, 1);  // set the cursor to column 0, line 1
lcd.print("Potenza prod.");

Nick_Pyner

Read reply #1 again.Then the 4th line of your code.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy