3D Ramp style (1 piece)
2D style piece (3 pieces)
// Code create by mark aruda for Mecanical Design Lab 1 at Umass Lowell | |
// Code moves 2 servos, the first moves based on the potentiometer value, | |
//the second servo moves between horizontal and vertical based on a pushbutton | |
//button attatched to 1 | |
//potentiometer attatched to A3 | |
//Servo 1 attatched to 9 | |
//Servo 2 attatched to 10 | |
//LCD attatched to 12, 11, 5, 4, 3, 2 http://www.arduino.cc/en/Tutorial/LiquidCrystal | |
//LCD RS pin to digital pin 12 | |
//LCD Enable pin to digital pin 11 | |
//LCD D4 pin to digital pin 5 | |
//LCD D5 pin to digital pin 4 | |
//LCD D6 pin to digital pin 3 | |
//LCD D7 pin to digital pin 2 | |
#include <Servo.h> //includes servo library | |
#include <LiquidCrystal.h>// include LCD display | |
Servo servo1; //servo control object | |
Servo servo2; | |
LiquidCrystal lcd(12,11,5,4,3,2);//sets up the LCD display array to those pins | |
const int buttonPin = 7; //labels button pin | |
const int potpin = A3; //labels analog read pin for potentiometer | |
int potposition; //creates value for potientiometer value | |
int servo1position; //creates variable for servo position | |
int servo1clockwiseSpeed = 100; //the speed to make the continuous servo go up | |
int servo1counterclockwiseSpeed = 80; //the speed to make the continuous servo go down | |
int servo1stop=90; //the adjusted servo position to make the servo stop | |
boolean currentState = LOW; //used for debounce code | |
boolean lastState = LOW; | |
boolean stateChange = false; | |
int currentButton = 0;// used for button count | |
int lastButton = 1; | |
// setup | |
void setup() { | |
lcd.begin(16,2); //to set the LCD to start with 16 coloums and 2 rows | |
servo1.attach(9); //servo1 attached pin 9 | |
servo2.attach(10); //servo2 attached pin 10 | |
pinMode(buttonPin, INPUT); //makes the button pin an input | |
lcd.clear(); | |
} | |
// main loop | |
void loop(){ | |
potposition= analogRead(potpin); //reads the potentiometer value and gives a value between 0-1023 | |
servo1position= map(potposition,0,1023,0,180); //maps the value from the potentiometer so it can work for a servo range | |
//if the potentiometer is between 80 or 100 the servo will not move and it will print stopped on the LCD | |
if ( servo1position >= 80 && servo1position <=100) | |
{ | |
servo1.write(servo1stop); | |
lcd.setCursor(0,0); | |
lcd.print("Stopped "); | |
} | |
//if the potentiometer is greater than 100 it will move in the positive direction and write that on the screen | |
if (servo1position > 100) | |
{ | |
servo1.write(servo1clockwiseSpeed); | |
lcd.setCursor(0,0); | |
lcd.print("Going up "); | |
} | |
//if the potentiometer is less than 100 it will go down and write that on the LCD screen | |
if (servo1position <80){ | |
servo1.write(servo1counterclockwiseSpeed); | |
lcd.setCursor(0,0); | |
lcd.print("Going down"); | |
} | |
//look at various function descriptions | |
currentState = debounceButton(); | |
stateChange = checkForChange(currentState, lastState); | |
currentButton = getButtonNumber(lastButton, currentState, stateChange); | |
indicatorLight(currentButton); | |
lastState = currentState; | |
lastButton = currentButton; | |
} | |
// function debounceButton to make sure the button is only pushed once | |
boolean debounceButton() | |
{ | |
boolean firstCheck = LOW; | |
boolean secondCheck = LOW; | |
boolean current = LOW; | |
firstCheck = digitalRead(buttonPin); | |
delay(50); | |
if (firstCheck == secondCheck){ | |
current = firstCheck; | |
} | |
return current; | |
} | |
// function checkForChange this function makes sure there is a change in whether the button is pushed or not | |
boolean checkForChange(boolean current, boolean last) | |
{ | |
boolean change; | |
if (current != last){ | |
change = true; | |
} | |
else { | |
change = false; | |
} | |
return change; | |
} | |
// function getButtonNumber means that if there is a change then the button count goes up by 1 untill it reaches 1 | |
// then it goes back to 0 | |
int getButtonNumber(int button, boolean state, boolean change) | |
{ | |
if (change == true && state == LOW){ | |
button++; | |
if (button > 1){ | |
button = 0; | |
} | |
} | |
return button; | |
} | |
// function indicatorLight this function will set the servo to 90 degrees or 0 degrees according to what button it is on | |
void indicatorLight(int button) //function that acts according to the button number that the get button number function gives out | |
{ | |
if (button==0) //if the button is 0 it makes the servo go to 90 degrees | |
{ | |
servo2.write(20); | |
lcd.setCursor(0,1); | |
lcd.print("Lever up "); | |
} | |
if (button ==1) // if the button number is 1 it makes the servo go to 180 degrees | |
{ // if the button number is 1 it makes the servo go to 180 degrees | |
servo2.write(90); | |
lcd.setCursor(0,1); | |
lcd.print("Lever Down"); | |
} | |
} |
Wheel Chair Lift Parts List | |
Quantity | Part name |
6 | 15 hole Lego beam |
2 | 1x4 thin lift arm |
2 | 1x9 bent lift arm (6-4) |
1 | 10 axle |
2 | 8 axle |
20 | connector pins |
4 | half bushings |
2 | 20 tooth gear |
2 | 1x16 hole brick |
6 | axle sleeves |
1 | 8 tooth gear |
6 | 1x3 hole brick |
2 | thin triangle Legos |
// Code create by mark aruda for Mecanical Design Lab 1 at Umass Lowell | |
// Code moves 2 servos, the first moves based on the potentiometer value, | |
//the second servo moves between horizontal and vertical based on a pushbutton | |
#include <Servo.h> //includes servo library | |
Servo servo1; //servo control object | |
Servo servo2; | |
const int buttonPin = 2; //labels button pin | |
const int potpin = A3; //labels analog read pin for potentiometer | |
int potposition; //creates value for potientiometer value | |
int servo1position; //creates variable for servo position | |
boolean currentState = LOW; | |
boolean lastState = LOW; | |
boolean stateChange = false; | |
int currentButton = 0;// used for button count | |
int lastButton = 2; | |
// setup | |
void setup() { | |
servo1.attach(9); //servo1 attached pin 9 | |
servo2.attach(10); //servo2 attached pin 10 | |
pinMode(buttonPin, INPUT); //makes the button pin an input | |
} | |
// main loop | |
void loop(){ | |
potposition= analogRead(potpin); //reads the potentiometer value and gives a value between 0-1023 | |
servo1position= map(potposition,0,1023,0,180); //maps the value from the potentiometer so it can work for a servo range | |
servo1.write(servo1position); //writes the servo to that value | |
currentState = debounceButton(); | |
stateChange = checkForChange(currentState, lastState); | |
currentButton = getButtonNumber(lastButton, currentState, stateChange); | |
indicatorLight(currentButton); | |
lastState = currentState; | |
lastButton = currentButton; | |
} | |
// function debounceButton | |
boolean debounceButton() | |
{ | |
boolean firstCheck = LOW; | |
boolean secondCheck = LOW; | |
boolean current = LOW; | |
firstCheck = digitalRead(buttonPin); | |
delay(50); | |
secondCheck = digitalRead(buttonPin); | |
if (firstCheck == secondCheck){ | |
current = firstCheck; | |
} | |
return current; | |
} | |
// function checkForChange | |
boolean checkForChange(boolean current, boolean last) | |
{ | |
boolean change; | |
if (current != last){ | |
change = true; | |
} | |
else { | |
change = false; | |
} | |
return change; | |
} | |
// function getButtonNumber | |
int getButtonNumber(int button, boolean state, boolean change) | |
{ | |
if (change == true && state == LOW){ | |
button++; | |
if (button > 2){ | |
button = 0; | |
} | |
Serial.println(button); | |
} | |
return button; | |
} | |
// function indicatorLight | |
void indicatorLight(int button) //function that acts according to the button number that the get button number function gives out | |
{ | |
if (button==0){ //if the button is 0 it makes the servo go to 90 degrees | |
servo2.write(90); | |
} | |
if (button == 1){ | |
//do nothing | |
} | |
if (button ==2) { // if the button number is 2 it makes the servo go to 180 degrees | |
servo2.write(0); | |
} | |
} | |
//things to add in the future lcd screen and indicator lights |
![]() |
Figure 1. Quick sketch of design |
![]() |
Figure 2. Real version of the lift
|