Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
int CS = 6; // Digipot chip select pin int UD = 4; // Digipot up / down int INC = 5; //Digipot increments int parkPin = 11; //park button int drivePin = 10; // drive button int val = 0; const int ledPinDrive = 8; // Testing LED's const int ledPinPark = 7; // Testing LED's const int sensorPin = A0; // wiper pin on Digipot const int thresholdDrive = 150; // testing threshold const int thresholdPark = 40; // testing threshold int buttonState1 = 0; int buttonState2 = 0; int sensorMin = 1023; int sensorMax = 0; int sensorDriveValue = 150; // testing threshold int sensorParkValue = 40; // testing threshold void setup() { // put your setup code here, to run once: pinMode(CS, OUTPUT); pinMode(UD, OUTPUT); pinMode(INC, OUTPUT); pinMode(parkPin, INPUT); pinMode(drivePin, INPUT); pinMode(ledPinDrive, OUTPUT); pinMode(ledPinPark, OUTPUT); digitalWrite(CS, HIGH); digitalWrite(UD, HIGH); digitalWrite(INC, HIGH); } void loop() { // put your main code here, to run repeatedly: { int buttonState1 = digitalRead(parkPin); // Button setup int buttonState2 = digitalRead(drivePin);// Button setup int analogvalue = analogRead(sensorPin); // setup to Read A0 val = analogRead(sensorPin); // value of A0 Serial.println(val); //AO in serial monitor delay(5); } // val = digitalRead(drivePin); // establishing pin while (digitalRead(parkPin) == HIGH) { // when park button is pushed, sketch goes park void. Park(); } while (digitalRead(drivePin) == HIGH) { // when drive button is pushed, sketch goes drive void. Drive(); } } void Drive() { int analogvalue = analogRead(sensorPin); digitalWrite(CS, LOW); //This is what is needed to adjust digitalWrite(UD, HIGH); //the Digitpot if (analogvalue >= sensorDriveValue) { digitalWrite(ledPinDrive, HIGH); // digitalWrite(CS, LOW); //This is what is needed to adjust // digitalWrite(UD, HIGH); //the Digitpot digitalWrite(INC, HIGH); //execute in this order } else { digitalWrite(ledPinDrive, LOW); // should do nothing } } void Park() { int analogvalue = analogRead(sensorPin); if (analogvalue >= sensorParkValue) { digitalWrite(ledPinPark, HIGH); // digitalWrite(CS, LOW); //This is what is needed to adjust // digitalWrite(UD, LOW); //the Digitpot // digitalWrite(INC, HIGH); //execute in this order } else { digitalWrite(ledPinPark, LOW); // should do nothing } } // // if (sensorParkValue <= sensorMax && sensorParkValue >= sensorMin){
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)