SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By randaza1
#160443
Having difficulty with the Sparkfun RTL-09877 Serial LCD

Using a potentiometer, I would like the coordinates to be displayed on the serial lcd, in real time.

For example, if the potentiometer is at 0 i would like to have the lcd display that number. If i turned the pot in any direction, where I leave the pot setting is the coordinate i would like displayed (using the coding of: 0, 1023, 0, 179)

Can anyone give me some insight as to what I will need to do..

Here is the code i am using - this portion of the program will turn 4 servos attached to the 4 potentiometers which I am speaking of.
PLEASE NOTE THAT THE CODING to make the servos operate is working fine, its just the coding to get the information from the pots to the serial lcd is where the problem lies.
//Beginning of Code

#include <Servo.h>
const int pan1 = 3; // first servo
const int tilt1 = 5; // second servo
const int pan2 = 6; // third servo
const int tilt2 = 9; // fourth servo

const int potpan1 = A0; // Pot 1 Vertical signal
int val0;
const int pottilt1 = A1; // Pot 2 Horizontal signal
int val1;
const int potpan2 = A2; // Pot 3 Select signal
int val2;
const int pottilt2= A3; // Pot4 Vertical signal
int val3;

int servoVal[4]; // variable to read the value from the analog pin

Servo mypan1; // create servo object to control a servo
Servo mytilt1; // create servo object to control a servo
Servo mypan2; // create servo object to control a servo
Servo mytilt2; // create servo object to control a servo

void setup()
{

// Servo
mypan1.attach(pan1); // attaches the servo
mytilt1.attach(tilt1); // attaches the servo
mypan2.attach(pan2); // attaches the servo
mytilt2.attach(tilt2); // attaches the servo

// Inizialize Serial
Serial.begin(57600);
}

void loop()
{

//outputPotentiometers(); // Read and output pot values

val0 = analogRead(potpan1); // reads the value of the potentiometer (value between 0 and 1023)
val0 = map(val0, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
outputPotentiometers(); // Read and output potentiometer values
mypan1.write(val0); // sets the servo position according to the scaled value


val1 = analogRead(pottilt1); // i added
val1 = map(val1, 0, 1023, 0, 179); // i added
outputPotentiometers(); // Read and output potentiometer values
mytilt1.write(val1); // i added


val2 = analogRead(potpan2); // i added
val2 = map(val2, 0, 1023, 0, 179); // i added
outputPotentiometers(); // Read and output potentiometer values
mypan2.write(val2); // i added



val3 = analogRead(pottilt2); // i added
val3 = map(val3, 0, 1023, 0, 179); // i added
outputPotentiometers(); // Read and output potentiometer values
mytilt2.write(val3); // i added

delay(1);
}

void outputPotentiometers() // Display potentiometer Values
{
Serial.print("P1~3: ");
Serial.print((val0));
Serial.print("\t");
Serial.print(" T1~5: ");
Serial.print((val1));
Serial.print("\t");
Serial.print(" P2~6: ");
Serial.print((val2));
Serial.print("\t");
Serial.print(" T2~9: ");
Serial.println((val3));
Serial.print("\t");

}
By randaza1
#160467
@Blackfin - at this time, nothing much. I did get the lcd to display some "static" information.
Due to the use of 4 potentiometers, I have requested the lcd to display the following:
1st row = T1: P1:
2nd row = T2: P2:

Just after the " : " is where I would like the coordinates for each pot to be displayed.
By Valen
#160495
Serial.print((val0));
Did this compile correctly? Are these extra curved brackets allowed syntax elements in Arduino-speak? They would be if there was a function name preceding the opening bracket. But there isn't.
By Mee_n_Mac
#160501
First things first ... what pins do you have the serial LCD wired up to ? From your code it appears you are sharing the single serial port (UART) btw the LCD and the USB connection. That is everything you send from the Arduino to the LCD should also go to the USB and thus to the serial monitor on the PC (if attached).

Second you have the baud rate on the serial-USB port (UART) set to 57,600. Did you change the baud rate on the serial LCD to match ? I would suggest leaving everything at 9600 until things get working. I don't believe the serial LCD supports that high (57600) a baud rate.

While this ... Serial.print((val0)); ... seems to compile, I think this is all that's needed ... Serial.print(val0);

ps - use the code tags
(click on to open)
CodeButtonTags.jpg
You do not have the required permissions to view the files attached to this post.
By randaza1
#160534
Hello everyone, I just wanted to take a moment and say thank you to all that have responded. I have been offline since Thursday evening...power outage....
I am back on obviously and will look over all the information and report back to you.

Thanks
Tony