Hello Friends, As i am new can't understand any logic of Program from some one i got the following Codes but i could not able to decode it.So Plz plz Help me.Thanks in advance and plz place comments in every lines.And give me some troubleshooting....
int val = 3;
long last = 100;
int stat = HIGH;
int stat2;
int contar;
int displayrpm;
int sens = 75;
int nPalas = 1;
int milliseconds = 1000;
float speed = A0;
float volt = A1;
float motorpin = 9;
int chargeingpin = 12;
int brack = 2;
int buttonbrack;
int brackindicator = 13;
void setup()
{
pinMode(volt, INPUT);
pinMode(brack, INPUT);
pinMode(chargeingpin, OUTPUT);
pinMode(motorpin, OUTPUT);
pinMode(brackindicator, OUTPUT);
Serial.begin(9600);
}
void loop()
{
val = analogRead(3);
if (val < sens)
stat = LOW;
else
stat = HIGH;
if (stat2 != stat)
{
contar++;
stat2 = stat;
}
if(millis() - last >= milliseconds)
{
double rpm = (2.0 * 60000.0 /(milliseconds));
displayrpm = rpm;
LCDPrint();
}
}
void LCDPrint();
{
lcd.clear(); // Start with a blank screen
lcd.setCursor (0, 0); // Set the cursor to the beginning
lcd.print("MPH = ");
lcd.print(mph);
lcd.setCursor (0,2); // Set the cursor to the SECOND ROW
lcd.print("KMP = ");
lcd.print(kph);
buttonbrack = digitalRead();
if (buttonbrack == HIGH)
{
digitalWrite (motorpin,LOW);
speed = analogRead(A0);
speed = speed ;
analogWrite (motorpin,speed);
/*auto accleleration */
float volt = analogRead(A1);
volt = volt *.00463000000;
Serial.println(volt);
Serial.println("V");
if (volt < 3.3){
digitalWrite(chargeingpin,HIGH);
Serial.print("CHARGING ON");
}
if (volt > 4.5){
digitalWrite(chargeingpin,LOW);
Serial.print("CHARGING OFF");
}
else{
}
delay(1000);
}
return;
}
hey thanks to everyone for replying me.let me tell you that i am just a student,and i got this program from my teacher who helped me to make my final year project.but i am not much familiar with all this kind of coding and programming i could not able to make it error freeeeeee.so in my project i used following things
1.lcd 20*4 >> displays mph and kph
2.hall effect sensor for sensing rpm.
3.brakebuttons used to not to start the dc motor.
4.auto acceleration concept may be covered in above program.
in above program all this things included.....i request some one to plz help me....to make it error freeeeeee
Moderator edit: Converted entire post from all caps to all lower-case. (Nick Gammon)
int val = 3; // defines a val variable with a width of 3
long last = 100; // ensures that the last val is 3-100 = -97
int stat = HIGH; // includes the statistics package, high priority
int stat2; // includes the second statistics package
int contar; // reverses the motor
int displayrpm; // this is a bug - it should say 'delayrpm'
int sens = 75; // senses a 75
int nPalas = 1; // (not sure what thi is - sorry)
int milliseconds = 1000; // there are 1000 miliseconds in an RPM
Whew! I'm all expained out. Does anyone else want to keep going? I don't have a degree, so the more people like this that pass their courses and get a peice of paper to wave around, the better.
int val = 3; // defines a val variable with a width of 3
long last = 100; // ensures that the last val is 3-100 = -97
int stat = HIGH; // includes the statistics package, high priority
int stat2; // includes the second statistics package
int contar; // reverses the motor
int displayrpm; // this is a bug - it should say 'delayrpm'
int sens = 75; // senses a 75
int nPalas = 1; // (not sure what thi is - sorry)
int milliseconds = 1000; // there are 1000 miliseconds in an RPM
Whew! I'm all expained out. Does anyone else want to keep going? I don't have a degree, so the more people like this that pass their courses and get a peice of paper to wave around, the better.
hey man thanks for sharing your valuable knowledge........
MorganS:
We can read that code and see what it does. It does it very well.
What do you want it to do? What is it doing that you don't want and what is it not doing that you do want?
jurs:
His job is to find people who happily will do his job.
Reminds me to "Tom Sawyer" by Mark Twain when Tom was given the task of painting a fence.
[/q
Delta_G:
Or in other words...
Please do my homework for me because I'm lazy and I want this degree even though I'm not willing to learn what I need to know to get it. Hopefully when I go for a new job they won't find out that I don't know what I'm doing.
this is not a Home work for me. I just want some helps to deocode this program....