You didn’t read this before posting a programming question hence some of your code appears to be in italics and you have given no indication of what the program should do and the problems that you are having.
Start by putting code tags around your code in your post then tell us what is wrong
#include <liquidcrystal.h></liquidcrystal.h>
This looks wrong for a start (note the use of code tags)
I'm guessing that your program either doesn't compile or it doesn't load or if it loads it doesn't do what you want it to.
If you tell us which of those it is and post (in full) any error messages you get and/or describe (in detail) what happens and what should happen that's different...then we may be able to help.
for(int i=0; i<strlen(mystg); i++)="" ="" {="" lcd.print(mystg);="" } <="" p=""></strlen(mystg);>Can you explain what this line of code is supposed to do and how ?
If I had the knowledge, I would have written it myself. As I wrote earlier, I am completely new to this. I’m going to build a vibrator feeder for fine powder. The DC engine I will use as a vibrator motor.
What’s wrong with the code? I can not make it work with my Arduino nano ATmega 328P
The glaring errors are in this line for(int i=0; i<strlen(mystg); i++)="" ="" {="" lcd.print(mystg);="" } <="" p=""></strlen(mystg);>but there are others.
Where did you get the code from ?
Was my guess as to your goal in reply #10 correct ?
Looks like the page is corrupted in someway. The code below compiles. No guarantee it works correctly.
//built in arduino Library.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
const int motorPin=9;
void setup()
{
pinMode(motorPin,OUTPUT);//make pin 9 an output pin
lcd.begin(16,2);
//clear old screen data
lcd.clear();
//text to be displayed on the screen
lcd.print("UnicornClockworks");
}
void loop()
{
lcd.begin(16,2);
//clear old screen data
lcd.clear();
//text to be displayed on the screen
lcd.print("UnicornClockworks");
int speed = map(analogRead(A0),0,1024,0,255);//map the potentiometer to the range of the motor speed
analogWrite (motorPin,speed);
int voltage = speed/255*4.5;
float motorSpeed=voltage*140/4.5; //calculating motor speed, 140 rpm for 4.5v
//(column 0) of the second line (line 1)
lcd.setCursor(0,1);
lcd.print("Speed is:");
char myStg[10];
sprintf(myStg,"%d",motorSpeed);
for(int i=0;i<strlen(myStg);i++)
{
lcd.print(myStg[i]);
}
lcd.setCursor(13,1);
lcd.print("RPM");
delay(100);
}
Thank you so much for all the help!
Everything seems to work now besides a problem I can not read the speed of the LCD screen?
what other improvements to the code do you think I’m going to do?
//built in arduino Library.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
const int motorPin=9;
void setup()
{
pinMode(motorPin,OUTPUT);//make pin 9 an output pin
lcd.begin(16,2);
//clear old screen data
lcd.clear();
//text to be displayed on the screen
lcd.print("Vibro motor");
}
void loop()
{
lcd.begin(16,2);
//clear old screen data
lcd.clear();
//text to be displayed on the screen
lcd.print("Vibro motor");
int speed = map(analogRead(A0),0,1024,0,255);//map the potentiometer to the range of the motor speed
analogWrite (motorPin,speed);
int voltage = speed/255*4;
float motorSpeed=voltage*140/4; //calculating motor speed, 140 rpm for 4v
//(column 0) of the second line (line 1)
lcd.setCursor(0,1);
lcd.print("Speed is:");
char myStg[10];
sprintf(myStg, "%d", motorSpeed);
for (int i = 0; i <strlen(myStg); i++)
{
lcd.print(myStg[i]);
}
lcd.setCursor(13,1);
lcd.print("RPM");
delay(100);
}
As to improvements, what happens if you simply position the cursor and print motorSpeed ? Do you actually need to turn it into a string using sprintf() then print each character separately ?