Want more features on Pastebin? Sign Up, it's FREE!
Guest

Failed Motor Shield R3 current sensing thru A0

By: a guest on Apr 30th, 2013  |  syntax: C++  |  size: 0.75 KB  |  views: 85  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. const int currentsensor = A0;
  2. int delay1 = 5000;
  3. int current;
  4.  
  5. void closewindow() {
  6.   digitalWrite(12, HIGH);
  7.   digitalWrite(9, LOW);
  8.   analogWrite(3, 1023);}
  9.  
  10. void openwindow() {
  11.   digitalWrite(12, LOW);
  12.   digitalWrite(9, LOW);
  13.   analogWrite(3, 1023);}
  14.  
  15. void motorkill() {
  16.   digitalWrite(12, LOW);
  17.   digitalWrite(9, LOW);
  18.   analogWrite(3, 0);} //stops the motor
  19.  
  20. void currentread() {
  21. analogRead(currentsensor);
  22. current = (currentsensor);
  23. Serial.println(current);}
  24.  
  25. void setup() {
  26. Serial.begin(9600);
  27.   pinMode(12, OUTPUT); //Initiates Motor Channel A pin                                      
  28.   pinMode(9, OUTPUT); //Initiates Brake Channel A pin  }
  29.  
  30. void loop() {
  31. openwindow();
  32. delay(500);
  33. currentread();
  34. delay(100);
clone this paste RAW Paste Data