Machining a Feed Ramp for an Arduino Vibe Bowl Screw Feeder!
Bill of Materials
Arduino Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #include <Wire.h> #include <Adafruit_RGBLCDShield.h> #include <utility/Adafruit_MCP23017.h> Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield(); int qty = 0; // quantity of parts counted int del = 50; // global debounce duration for buttons int set = 0; // user input number of parts to be counted uint8_t i = 0; // reads button input const int signalPin = A0; // set up a constant for the photointerrupt signal pin int switchState = 0; // variable to hold the value of the switchPin int prevSwitchState = 0; // variable to hold previous value of the switchpin int pwr = 13; // power pin to vibration on/off relay void setup() { pinMode(signalPin, INPUT); // set up the switch pin as an input pinMode(pwr, OUTPUT); // set pwr pin to output lcd.begin(16, 2); // set up the LCD's number of columns and rows lcd.setCursor(0, 0); lcd.print("SET QTY"); // print LCD column headers } void loop() { lcd.setCursor(0, 1); lcd.print(set); // print "set" to LCD lcd.setCursor(13, 1); lcd.print(qty); // print "qty" to LCD uint8_t buttons = lcd.readButtons(); if (buttons) // if any button is pressed { lcd.setCursor(0, 1); lcd.print(" "); //clear LCD bottom row for new values if (buttons & BUTTON_UP && set <= 998) // if "UP" button is pressed { set = set + 1; // increase "set" value by one delay(del); // debounce } if (buttons & BUTTON_DOWN && set >= 1) // if "DOWN" button is pressed { set = set - 1; // decrease "set value by one delay(del); //debounce } if (buttons & BUTTON_RIGHT && set <= 989) // if "RIGHT" button is pressed { set = set + 10; // increase "set" value by ten delay(del); // debounce } if (buttons & BUTTON_LEFT && set >= 10) // if "LEFT" button is pressed { set = set - 10; // increase "set" value by ten delay(del); // debounce } if (buttons & BUTTON_SELECT) // if "SELECT" button is pressed { digitalWrite(pwr, HIGH); // start vibration delay(del); // debounce } } switchState = analogRead(signalPin); // check the status of the photointerrupt if (switchState != prevSwitchState) // compare the switchState to its previous state { if (switchState == LOW) // if photointerrupt detects a part { qty = qty + 1; // increment part count by one delay(20); // debounce } } { if (qty == set) { delay(400); // delay to clear ramp of counted pieces before stopping vibration. digitalWrite(pwr, LOW); // stop vibration qty -= qty; // reset counted part quantity lcd.setCursor(14, 1); lcd.print(" "); // write LCD qty zero } prevSwitchState = switchState; // reset photointerrupt's state } } |
Related Videos & Resources:
The Imperializer: MM to Inch Conversion Box!
Arduino Stepper & Servo Sorting Machine! Video on Design, Functionality and Arduino Code!