oh my god
have some problems with the motor today, the program could not be tested .
i have a question about the LCD
now i am using "lcd.clear();" to clear the previous speed
so the speed keep blinking.
however, i would like to keep the the number. When no speed, it will return to zero. If there is a speed, it will have a speed showing,
it maybe confused that you guys don't know what i am talking about
if you have question, ask me please.
"lcd.clear()" only needs to be called if the value you are about to write to the LCD is different to the value that you last wrote to it.
That will eliminate some of the blinking.
lcd.clear()" only needs to be called if the value you are about to write to the LCD is different to the value that you last wrote to it.
That will eliminate some of the blinking.
Yes
umm
but now i would like to do this, that is
when a value shown like this "40.0"
the second is , "50.0"
however, the 40.0 is changed to 50 by jumping, not clearing the 40, and print 50
Have you got the frequency measurement working properly?
about that, it is night time now in Hong Kong, so i gotta try this tomorrow
today, there is a problem with the motor, it is smoking, help me god.
i hope there is other motor to replace it.
i will keep you guys informed, and thanks again
i love you guys ;D
Oh my god...
it keeps showing nothing to me
just 0.00
the current code is here
#define frqPin = 1;
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
long timeStart, timeStop;
void setup() {
pinMode(1, INPUT);
lcd.begin(16, 2);
Serial.begin(9600);
}
void loop()
{
pulseIn(1, LOW); // Wait for pin to go LOW
unsigned long t1 = pulseIn(1, HIGH);// Time how long it takes to go HIGH again
unsigned long t2 = pulseIn(1, LOW); // and how long it takes to go low again.
double t = t1 + t2;
double f = 1000000.0/t;
double w = 2 * 3.14 * f;
double v = w * 2 * 3.14 * 0.01666667;
double s = w * 0.05;
lcd.println(s);
delay(1000);
lcd.clear();
}
Ah , i saw that i forgot to cancel the long timestart and stop
will it afftect the pulse in funtion ?
You've got a "Serial.begin" in your sketch - I assume you'd want to use it at some point.
Try this:
#define FREQ_PIN 2
void setup() {
pinMode(FREQ_PIN, INPUT);
Serial.begin(9600);
analogWrite (3, 128); //start a roughly 50% duty cycle on digital pin 3
}
void loop()
{
while (digitalRead (FREQ_PIN) == LOW)
{}
unsigned long t1 = pulseIn(FREQ_PIN, HIGH);// Time how long it takes to go HIGH again
unsigned long t2 = pulseIn(FREQ_PIN, LOW); // and how long it takes to go low again.
Serial.println (t1);
Serial.println (t2);
delay(1000);
}
Jumper pin 2 to pin 3, and run the serial monitor.
You've got a "Serial.begin" in your sketch - I assume you'd want to use it at some point.
ah , i am sorry
i thought this code is needed in every script.
i didn't want to use the serial print.
#define FREQ_PIN 2
void setup() {
pinMode(FREQ_PIN, INPUT);
Serial.begin(9600);
analogWrite (3, 128); //start a roughly 50% duty cycle on digital pin 3
}
void loop()
{
while (digitalRead (FREQ_PIN) = LOW)
{}
unsigned long t1 = pulseIn(FREQ_PIN, HIGH);// Time how long it takes to go HIGH again
unsigned long t2 = pulseIn(FREQ_PIN, LOW); // and how long it takes to go low again.
Serial.println (t1);
Serial.println (t2);
delay(1000);
}
what is the analogWrite for ?
and, i saw that there is a code on the arduino page, "unsigned long duration;"
it is necessary being written in the code for using unsigned long t1 or t2 ?
I suggest you keep things simple until you familiarise yourself with the code and get the pulseIn functionality working. So it may be better at first to use serial rather than the LCD code.
You can add the LCD code and conversion from period to frequency after you confirm you are able to measure the pulses.
If you are using a standard arduino board its best to stay away from the pins used by the serial port, so frqPin is set to pin 2
oh, theoretically, the t1 and t2 can be measured ?
today, i found out that, about the voltage output range
the higher output is around 2.5 - 4.6V
the lower output is around 1.6 - 2.4V
if the lower output could not reach to 0V, the pulse can still be measured?