SHARE
TWEET

Failed Motor Shield R3 current sensing thru A0

a guest Apr 30th, 2013 85 Never
  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);
RAW Paste Data
Top