Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- //
- //
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
- #define pot_in A3
- #define rocker 9
- #define PUL 7
- #define DIR 6
- #define ENA 5
- void setup() {
- lcd.begin(20, 4);
- lcd.setCursor(0, 0);
- lcd.print("Welcome to");
- lcd.setCursor(0, 1);
- lcd.print("Team Plastic");
- lcd.setCursor(0, 2);
- lcd.print("String Theory's");
- lcd.setCursor(0, 3);
- lcd.print("Plastic Extruder!");
- pinMode (PUL, OUTPUT);
- pinMode (DIR, OUTPUT);
- pinMode (ENA, OUTPUT);
- pinMode (pot_in, INPUT);
- pinMode (rocker, INPUT);
- int minimum_speed_delay = 50;
- int maximum_speed_delay = 1;
- int acceleration_delay = 2;
- int count = 0;
- int current_speed_delay = 100;
- delay(5000);
- }
- void loop() {
- if (digitalRead(rocker) == HIGH) {
- if (count == 0) { //Initial acceleration to minimum speed
- lcd.clear();
- lcd.setCursor(0, 1);
- lcd.print("Motor is");
- lcd.setCursor(0, 2);
- lcd.print("accelerating");
- int current_speed_delay = 0;
- while (current_speed_delay > minimum_speed_delay) {
- digitalWrite(DIR, LOW);
- digitalWrite(ENA, HIGH);
- digitalWrite(PUL, HIGH);
- delayMicroseconds(current_speed_delay);
- digitalWrite(PUL, LOW);
- delayMicroseconds(current_speed_delay);
- int current_speed_delay = current_speed_delay - acceleration_delay;
- int count = count + 1;
- }
- }
- else if (count > 0) { //Motor speed = multiple of potiometer reading
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Motor is operating");
- lcd.setCursor(0, 2);
- lcd.print("at");
- lcd.setCursor(8, 2);
- lcd.print("RPMs");
- while (digitalRead(rocker) == HIGH) {
- digitalWrite(DIR, LOW);
- digitalWrite(ENA, HIGH);
- digitalWrite(PUL, HIGH);
- delayMicroseconds(current_speed_delay);
- digitalWrite(PUL, LOW);
- delayMicroseconds(current_speed_delay);
- int potent = analogRead(pot_in);
- current_speed_delay = constrain(potent, maximum_speed_delay, minimum_speed_delay);
- int count = count + 1;
- lcd.setCursor(3, 2);
- lcd.print(int(current_speed_delay));
- }
- }
- }
- else if (digitalRead(rocker) == LOW) { //Turning motor off
- if (count > 0) { //Deceleration to 0
- lcd.clear();
- lcd.setCursor(0, 1);
- lcd.print("Motor is");
- lcd.setCursor(0, 2);
- lcd.print("decelerating");
- while (current_speed_delay < 100) {
- digitalWrite(DIR, LOW);
- digitalWrite(ENA, HIGH);
- digitalWrite(PUL, HIGH);
- delayMicroseconds(current_speed_delay);
- digitalWrite(PUL, LOW);
- delayMicroseconds(current_speed_delay);
- int current_speed_delay = current_speed_delay + acceleration_delay;
- int count = count + 1;
- int count = 0;
- }
- }
- else if (count == 0) { //Motor speed = 0
- lcd.clear();
- lcd.setCursor(3, 1);
- lcd.print("Motor is off");
- while (digitalRead(rocker) == LOW) {
- delay(10);
- }
- }
- }
- }
- ------------------
- Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Uno"
- C:\Users\zhowe\Google Drive (zhowell@mymail.mines.edu)\10-19 Current Semester [Fall 2019]\[MEGN 301] Mechanical Integration & Design\Extruder Project\Stepper Motor Code\Stepper_Code_without_accel\Stepper_Code_without_accel.ino: In function 'void loop()':
- Stepper_Code_without_accel:44:9: error: 'count' was not declared in this scope
- if (count == 0) { //Initial acceleration to minimum speed
- ^~~~~
- C:\Users\zhowe\Google Drive (zhowell@mymail.mines.edu)\10-19 Current Semester [Fall 2019]\[MEGN 301] Mechanical Integration & Design\Extruder Project\Stepper Motor Code\Stepper_Code_without_accel\Stepper_Code_without_accel.ino:44:9: note: suggested alternative: 'round'
- if (count == 0) { //Initial acceleration to minimum speed
- ^~~~~
- round
- Stepper_Code_without_accel:51:36: error: 'minimum_speed_delay' was not declared in this scope
- while (current_speed_delay > minimum_speed_delay) {
- ^~~~~~~~~~~~~~~~~~~
- C:\Users\zhowe\Google Drive (zhowell@mymail.mines.edu)\10-19 Current Semester [Fall 2019]\[MEGN 301] Mechanical Integration & Design\Extruder Project\Stepper Motor Code\Stepper_Code_without_accel\Stepper_Code_without_accel.ino:51:36: note: suggested alternative: 'current_speed_delay'
- while (current_speed_delay > minimum_speed_delay) {
- ^~~~~~~~~~~~~~~~~~~
- current_speed_delay
- Stepper_Code_without_accel:58:57: error: 'acceleration_delay' was not declared in this scope
- int current_speed_delay = current_speed_delay - acceleration_delay;
- ^~~~~~~~~~~~~~~~~~
- Stepper_Code_without_accel:74:27: error: 'current_speed_delay' was not declared in this scope
- delayMicroseconds(current_speed_delay);
- ^~~~~~~~~~~~~~~~~~~
- In file included from sketch\Stepper_Code_without_accel.ino.cpp:1:0:
- Stepper_Code_without_accel:78:49: error: 'maximum_speed_delay' was not declared in this scope
- current_speed_delay = constrain(potent, maximum_speed_delay, minimum_speed_delay);
- ^
- C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:95:41: note: in definition of macro 'constrain'
- #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
- ^~~
- Stepper_Code_without_accel:78:70: error: 'minimum_speed_delay' was not declared in this scope
- current_speed_delay = constrain(potent, maximum_speed_delay, minimum_speed_delay);
- ^
- C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:95:60: note: in definition of macro 'constrain'
- #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
- ^~~~
- Stepper_Code_without_accel:87:9: error: 'count' was not declared in this scope
- if (count > 0) { //Deceleration to 0
- ^~~~~
- C:\Users\zhowe\Google Drive (zhowell@mymail.mines.edu)\10-19 Current Semester [Fall 2019]\[MEGN 301] Mechanical Integration & Design\Extruder Project\Stepper Motor Code\Stepper_Code_without_accel\Stepper_Code_without_accel.ino:87:9: note: suggested alternative: 'round'
- if (count > 0) { //Deceleration to 0
- ^~~~~
- round
- Stepper_Code_without_accel:93:14: error: 'current_speed_delay' was not declared in this scope
- while (current_speed_delay < 100) {
- ^~~~~~~~~~~~~~~~~~~
- Stepper_Code_without_accel:100:57: error: 'acceleration_delay' was not declared in this scope
- int current_speed_delay = current_speed_delay + acceleration_delay;
- ^~~~~~~~~~~~~~~~~~
- Stepper_Code_without_accel:102:13: error: redeclaration of 'int count'
- int count = 0;
- ^~~~~
- C:\Users\zhowe\Google Drive (zhowell@mymail.mines.edu)\10-19 Current Semester [Fall 2019]\[MEGN 301] Mechanical Integration & Design\Extruder Project\Stepper Motor Code\Stepper_Code_without_accel\Stepper_Code_without_accel.ino:101:13: note: 'int count' previously declared here
- int count = count + 1;
- ^~~~~
- Multiple libraries were found for "Wire.h"
- Used: C:\Program
- Multiple libraries were found for "LiquidCrystal_I2C.h"
- Used: C:\Users\zhowe\Documents\Arduino\libraries\NewLiquidCrystal_lib
- exit status 1
- 'count' was not declared in this scope
- This report would have more information with
- "Show verbose output during compilation"
- option enabled in File -> Preferences.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement