I'm trying to implement a button but I don't know how D: please help
Codes:
int referenceVoltage = 5; // use the default voltage as a reference
int initialReading; // raw value pulled of analog pin
float initialVoltage; // real voltage converted from reading
int analogValue; // store the analog reading here
int analogPin = 0; //use A0 as the analog pin
int shortPin = 3; // use pin D0 to turn on the transistor which will short the battery
int startButton = 4; // Use D4 pin to register when a button is pushed.
const int numberOfMeasurements = 20; // take 20 readings each time
int Stored[numberOfMeasurements];
int numReadings = 200; //Change this when you know how many readings you want!!!!!!
float volt;
int refvolt = 5;
int msec = 0;
void setup() {
delay(50);
initialReading = analogRead(analogPin); // get the battery's initial voltage
initialVoltage = initialReading * referenceVoltage / 1024;
Serial.begin(9600);
if (analogPin); {
Serial.print(analogPin);
msec = millis();
}
}
void loop() {
for (int i = 0; i < numReadings; i++) {
volt = volt + analogRead(analogPin);
}
digitalWrite(shortPin, HIGH);
delay(500);
volt = volt / numReadings / 1024 * refvolt;
Serial.print(volt);
Serial.println('Battery Recovery Profile');
volt = 0;
delay(10); {
Serial.print(millis() - msec);
Serial.print(" ");
}
}
Okay, I'll use the code button next time, sorry, new to all this stuff and yes, I have looked at the button examples but I still don't get it (sorry).
So, I haven't put in any codes for the button in either void setup/loop because I'm not sure what I'm supposed to put in. What I want to happen is, when I use the button, time ( Serial.print(millis() - msec); Serial.print(" ") will begin to be displayed in the serial monitor. I hope that clears things up and thank you for the reply.
What I want to happen is, when I use the button, time ( Serial.print(millis() - msec); Serial.print(" ") will begin to be displayed in the serial monitor.
Please read the above quote, I have just dropped in from Mars and have no idea what you are talking about.
Please tell us
What your application is.
What you want the program to do, as in input and outputs.
What you want the buttton to do.
Then read what you have written, if it sounds logical then post it.