code line lcd.scrollDisplayLeft (); no working - arduino

I use the library "LiquidCrystal_I2C.h" and "Wire.h".
The code line lcd.scrollDisplayLeft (); does not run the function.
Do I need to put this before / after the Lcd.print?
Should I put in after delay?
Is it related to the library?
It's just part of the code
lcd.clear;
lcd.scrollDisplayLeft();
lcd.print("press Up to set turn on");
lcd.setCursor(0, 1);
lcd.print("press down to set turn off");
Setting = true;
Thank you!

From https://www.arduino.cc/en/Reference/LiquidCrystalScrollDisplayLeft
Description Scrolls the contents of the display (text and cursor) one
space to the left.
So you clear the LCD, then you scroll an empty LCD 1 space to the left and then you print something. I don't know what happens after as you did not show your entire code.
I don't know how the LCD behaves. Either the scroll is ignored if there is no content or you do not recognize the 1 space change.
In most examples I've seen, this function is used in a loop. Your question suggests, that you did not consult the reference manual.

Related

Vibrationsensor keeps giving us the same value and it doesn't change when we "vibrate" it

We want to get the value of our vibrationsensor but it keeps giving us the value "677". We are new to programming so we don't really know how to fix this. The problem we encountered is in Arduino IDE
We tried to change the Serial.begin number but that was just a desperate call for help which obviously didn't work. We also tried to put the the power input in another port. First we put it in the 5V port, but it only gave us the value 1023, which is the max (I think). But then we put it in the 3.5V port and it gave us 677, which is a bit better but it doesn't change no matter how much we vibrate it.
Our code is:
int vibrationsensor = A0;
int vibrationvalue;
void setup()
{
pinMode(vibrationsensor, INPUT);
Serial.begin(9600);
}
void loop()
{
vibrationvalue = analogRead(vibrationsensor);
Serial.println(vibrationvalue);
delay(300);
}
We expected that the output would be consistent when the area is not vibrating and that it would change when we would vibrate it. But at this moment it just gives us 677 which isn't exactly wrong IF the area isn't vibrating, but it stays 677 even when we vibrate it.
As mentionned is a reference for your sensor:
it will react to shock and vibration by closing the circuit.
So, this vibration sensor is working in an ON/OFF mode: it will not return a analogic values of the vibration, it will only tell you if there is a shock or not. Seems that this sensor is not adapted to what you want to perform.
Hope it helps,

qt app that takes in textedit barcode scanned, how to change focus between two fields

So for me the plan is like this:
I scan a barcode, it gets in first textedit;
I scan another barcode, it gets in the second textedit,
in this case i use focus and keyboard event.
my problem is when i scan first code it is fine but when I scan the second code, some of letters go to second texedit some go to first texedit.
I don't understand what is the problem
here is my code
void CWidget::keyPressEvent(QKeyEvent *event)
{
if(focusWidget() == ui->lePath && !ui->lePath->text().isEmpty())
{
ui->leInformation->setFocus(); //leInformation second edit
ui->leInformation->setFocusPolicy(Qt::StrongFocus);
ui->leInformation->KeyPressEvent(event);
}
else
{
ui->lePath->setFocus(); //lePath - first edit text, first code scanned //goes here
ui->lePath->setFocusPolicy(Qt::StrongFocus);
ui->lePath->KeyPressEvent(event);
}
}
like is a strange think cause sometimes works sometimes no, if both codes scanned have digits they work but if the second scanned code has uppercase letters they go from the first uppercase letters they are wrote to first edit. but if they are lowercase they are fine again. I m thinking it is a problem with keyboard event how they deal with uppercase. somehow maybe with shift, and they change between two edits.
if there is someone who has an idea on how i can properly write that keyboard event, please help thanks
here B should have been on the second. I'm being sure on how uppercase are being entered on keyboard event is about shift + letter and shift moves you to the other edit but how i can change this

Writing to Arduino's serial monitor box

I'm trying to send SMS using GPRS attached to Arduino.
I have this code:
// send an SMS!
char sendto[21], message[141];
flushSerial();
Serial.print(F("Send to #"));
readline(sendto, 20);
Serial.println(sendto);
Serial.print(F("Type out one-line message (140 char): "));
readline(message, 140);
Serial.println(message);
if (!fona.sendSMS(sendto, message)) {
Serial.println(F("Failed"));
} else {
Serial.println(F("Sent!"));
}
I tried to send, and it is working perfect, but I have to use the serial monitor box to enter the number and the message, and the library is using only this method. I want the code to run by itself without entering anything in the box.
Is there is any way so I can do that? I mean something like writing automatically to the box from the code.
Thank you in advance!
Best regards,
Take out the parts of the code that read the line from the Serial monitor and replace with lines of code that either have the data it needs hard-coded or has some other way to get that data. You really haven't shown enough of the code to help you figure out how to do that.

Strange initial output using Serial.print

When I'm writing to the serial interface, I'm getting strange and unexpected output when my sketches first run. The output seems to be a variant of what should be printed:
eg:
String text1 = "foobar";
void setup() {
Serial.begin(9600);
Serial.print("\n");
Serial.print(text1);
}
void loop() {
}
Results in the output:
fo
foobar
(the new line appears before "fo" but I couldn't work out how to include it).
So some variant of whatever is supposed to be printed, gets printed before the actual text that is supposed to be printed. Changing the output, changes the anomalous text (sometimes it'll be two characters, sometimes three). Making changes that don't affect the output and recompiling has no effect on the anomalous text.
I'm a total Arduino newbie (I only started writing my own code today), but I can only assume this isn't normal.
I'm using a Freetronics EtherTen and the 1.0 IDE
thanks in advance
Arduino is restarting your sketch when you open its serial port on the computer.
so it prints out, and then initialized again.
after
Serial.begin(9600);
try to put either:
delay(500)
or
while (!Serial); // while the serial stream is not open, do nothing:
This is most likely a Serial communication Reset issue as Eran W pointed out. See my previous answer here.
The Arduino automatically resets when it receives serial communication from most things other than the Arduino IDE. This is why you can send from the IDE but not anything else.
I have an Uno and put a capacitor between Reset and Ground.Here's a page with some good info on the subject.
Good luck. http://arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection
You should probably terminate your string with a 0.
Like:
String text1 = "foobar",0;

How to make the vertical scrollbar follow the data?

In a VC++ 6.0 MFC of mine, I added an EditBox with Vertical Scrollbar, every 10 seconds I am reading data from serial port and I have to display through EditBox(IDC_EDIT1), I done it without any problems.
But one typical problem I am facing which is that, whenever a new data displayed in the EditBox the vertical scrollbar goes up and data remains down, I have to scroll down every time to read the data.
So my question is whenever a new data display in EditBox the vertical scrollbar also has to move down along with the data.
How can i do this?
You will need to send the edit control an EM_SETSEL message with the length of the string as the parameters.
Also if your EditBox is CEdit, you can try following its member functions
void SetSel(
DWORD dwSelection,
BOOL bNoScroll = FALSE
);
void SetSel(
int nStartChar,
int nEndChar,
BOOL bNoScroll = FALSE
);
You can send a message to the control:
SendMessage(hwnd, WM_VSCROLL, SB_BOTTOM, 0);
where hwnd is the handle of your editbox

Resources