materials for TeZ Bioreactor course
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
704 B

  1. // WEMOS D1 MINI ESP32 // MOTOR TEST (with TIP 120) // TeZ 2022
  2. #include <Arduino.h>
  3. #include <analogWrite.h>
  4. #define MOTORPIN 26
  5. int powerStep = 1;
  6. int power = 0;
  7. /////////////////////////////////////////
  8. void setup() {
  9. // Set resolution for a specific pin
  10. analogWriteResolution(MOTORPIN, 12);
  11. for(int n=0; n<3; n++){
  12. analogWrite(MOTORPIN, 200);
  13. digitalWrite(2,HIGH);
  14. delay(500);
  15. analogWrite(MOTORPIN, 0);
  16. digitalWrite(2,LOW);
  17. delay(500);
  18. }
  19. }
  20. /////////////////////////////////////////
  21. void loop() {
  22. power += powerStep;
  23. if ( power == 0 || power == 255 ) {
  24. powerStep = -powerStep;
  25. }
  26. analogWrite(MOTORPIN, power);
  27. analogWrite(2, power);
  28. delay(10);
  29. }