Skip navigation
2013

I have an Arduino Due interfeced to an LCD (4 line x 20 char).

Its a standard connection scheme using all 8 data bits in this case.

Here is my issue:

I have a program that prints values from 7 analog inputs A0-A6.

I write to A0-A3 in char position 0, lines 0-3 and A4-A6 in char position 01, lines 0-2 in a continuos loop.

My problem is the postion of each value start out as ok but after a little while the items bounce around in

location and it all gets messed up.  Im puzzled.  Can anyone offer ideas?  Ive tried quite a bit to fix it.

Here is my code that Im running in the Arduino Due.

Thanks.

 

Ken

 

 

/****************************************************************************/
#include <LiquidCrystal.h>
/****************************************************************************/
int led = 13;
//LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd(12, 11, 9, 8, 7, 6, 5, 4, 3, 2);

/****************************************************************************/
void setup()
{
  // put your setup code here, to run once:
      
pinMode(led, OUTPUT); // initialize the digital pin as an output.
 
Serial1.begin(9600); // initialize serial communication at 9600 bits per second:
lcd.begin(20,4);
lcd.clear();
lcd.home();
lcd.noCursor();

}

void loop() {
   // read the input on analog inputs A0-A6:

      analogReadResolution(12);   // sat analog read resolution to 12 bit, 0-4095
      int sensor0 = analogRead(A0);int sensor1 = analogRead(A1);int sensor2 = analogRead(A2);int sensor3 = analogRead(A3);int sensor4 = analogRead(A4);int sensor5 = analogRead(A5);int sensor6 = analogRead(A6);
        
   // Convert the analog reading (which goes from 0 - 4095) to a voltage (0 - 3.3V):
  
    float sensorV0 = sensor0 * (3.3 / 4095.0);
    float sensorV1 = sensor1 * (3.3 / 4095.0);
    float sensorV2 = sensor2 * (3.3 / 4095.0);
    float sensorV3 = sensor3 * (3.3 / 4095.0);
    float sensorV4 = sensor4 * (3.3 / 4095.0);
    float sensorV5 = sensor5 * (3.3 / 4095.0);
    float sensorV6 = sensor6 * (3.3 / 4095.0);

   // print out tthe (7) analog values
Serial1.print("A0=");Serial1.print(sensorV0,3); Serial1.print("\t");
Serial1.print("A1="); Serial1.print(sensorV1,3);Serial1.print("\t");
Serial1.print("A2=");Serial1.print(sensorV2,3); Serial1.print("\t");
Serial1.print("A3="); Serial1.print(sensorV3,3); Serial1.print("\t");
Serial1.print("A4=");Serial1.print(sensorV4,3); Serial1.print("\t");
Serial1.print("A5="); Serial1.print(sensorV5,3);Serial1.print("\t");
Serial1.print("A6=");Serial1.println(sensorV6,3);

//lcd.setCursor(0,0);
//lcd.print("A6=");lcd.print(sensorV6,3);
lcd.clear();
//lcd.setCursor(0,0);
lcd.print("A0= ");lcd.print(sensorV0,3);
lcd.setCursor(0,1);lcd.print("A1= ");lcd.print(sensorV1,3);
lcd.setCursor(0,2);lcd.print("A2= ");lcd.print(sensorV2,3);
lcd.setCursor(0,3);lcd.print("A3= ");lcd.print(sensorV3,3);
lcd.setCursor(11,0);lcd.print("A4= ");lcd.print(sensorV4,3);
lcd.setCursor(11,1);lcd.print("A5= ");lcd.print(sensorV5,3);
lcd.setCursor(11,2);lcd.print("A6= ");lcd.print(sensorV6,3);

 
digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
delay(250);               // wait for a second
digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW

  
delay(500); // a little delay to not hog serial monitor
   // bottom of loop
}

A mini shield made from parts I had to spare, some tripad board, a couple of resistors and some header pins. I tried to space the pins out to give it some stability. The stripboard pins I used to provide connectors to the bus/power have been in the shed for many years now and really did not want to take the solder, perhaps it's time to get some new ones?

I2CMiniShield.JPG

I2CMiniShield2.JPG

Filter Blog

By date: By tag: