Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- int ledPin=13;
- int potPin=A0;
- void setup()
- {
- Serial.begin(38400);
- pinMode(potPin, INPUT);
- pinMode(ledPin, OUTPUT);
- }
- void loop()
- {
- int potPin=A0;
- int potVal1=analogRead(potPin);
- delay(640);
- int potVal2=analogRead(potPin);
- int rSpeed=potVal2-potVal1;
- Serial.print("Velocity over last 690ms: ");
- Serial.println(rSpeed);
- Serial.print("Current Pot Position: ");
- Serial.println(potVal2);
- isIncreasing(potVal1, potVal2, ledPin);
- }
- void isIncreasing(int potVal1, int potVal2, int ledPin)
- {
- if (potVal2<potVal1)
- {
- boolean isIncreasing=true;
- digitalWrite(ledPin, HIGH);
- }
- else
- {
- boolean isIncreasing=false;
- digitalWrite(ledPin, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement