Wearable project. Glove.
Project description:
A glove with five buttons and an LCD screen.
each button has a value and when pressed an array with letters in it is accessed and displayed on the LCD screen (on the second line). once you have the letter you want you can press the fifth button to store that letter in a new array. the second array is then displayed on the first line of the LCD screen.
Fritzing layout:
Video of it working:
Arduino Code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12,11,5,4,3,2);
#define LCD_LIGHT_PIN A4
const int oneButtonPin = 6;
const int twoButtonPin = 7;
const int threeButtonPin = 8;
const int fourButtonPin = 9;
const int fiveButtonPin = 10;
int button1State = 0;
int button2State = 0;
int button3State = 0;
int button4State = 0;
int button5State = 0;
//Set output number
int output = 0;
//set sentance size
const int sentSize = 20;
//Init sentence
char chosenSentance[sentSize];
//Init position
int position =0;
void setup() {
Serial.begin(9600);
// Setup the number of columns and rows that are available on the LCD.
lcd.begin(16, 2);
lcd.noDisplay();
// Set the button pins as an input.
pinMode(oneButtonPin, INPUT);
pinMode(twoButtonPin, INPUT);
pinMode(threeButtonPin, INPUT);
pinMode(fourButtonPin, INPUT);
pinMode(fiveButtonPin, INPUT);
// Set the LCD display backlight pin as an output.
pinMode(LCD_LIGHT_PIN, OUTPUT);
// Turn off the LCD backlight.
digitalWrite(LCD_LIGHT_PIN, LOW);
}
void loop() {
readState();
char alphabet[16] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'};
char chosen;
button5State = digitalRead(fiveButtonPin);
if (output >=1){
lcd.setCursor(0,1);
lcd.print(alphabet[output-=1]);
//lcd.print(output);
digitalWrite(LCD_LIGHT_PIN, HIGH);
lcd.display();
if (button5State == HIGH){
chosen = (alphabet[output]);
lcd.setCursor(position,0);
lcd.print(chosen);
//Add letter to sentence
chosenSentance[position++]=chosen;
Serial.println(chosenSentance);
delay(500);
}
output = 0;
}
if (position>=sentSize){
position = 0;
}
}
int readState(){
//Read buttons
button1State = digitalRead(oneButtonPin);
button2State = digitalRead(twoButtonPin);
button3State = digitalRead(threeButtonPin);
button4State = digitalRead(fourButtonPin);
//Encode to output
if (button1State == HIGH){
output+=1;
}
if (button2State == HIGH){
output+=2;
}
if (button3State == HIGH){
output+=4;
}
if (button4State == HIGH){
output+=8;
}
return output;
}
void clear(){
lcd.clear();
lcd.setCursor(0, 0);
}
Project reflection:
1) Where did you get the from?
Years ago I had a dream where I was taught to count in binary on my fingers. Using that idea I thought that if I placed buttons on my fingers I could type out a sentence and display that sentence on an LCD screen that was placed on the back of my hand.
2) Did your original idea change?
At first I wanted to give the user the ability to choose from all the letters of the alphabet and still can if I developed this idea further. As it sits they can choose 16 letters with 4 buttons, the fifth button is there to confirm that you want to add that letter to the sentence you are constructing.
3) What was hard and easy?
As I am not a coder I found some parts of the code challenging to get my head around.
4) What would you do differently next time?
I would spend more time on the project and add another button so the user can have access to the whole alphabet.
5) Could this project be extended?
this project could easily be extended for eg adding bluetooth so as to send the chosen sentence to your phone.
No comments:
Post a Comment