(trying not to sound cliche...)
serial.print("hello, arduino.cc/forum/ !!!");
Intro:
I am a complete n00b when it comes to microcontrollers. I bought a picaxe a couple years ago, and tried messing with it but eventually lost interest because it was confusing me and I really had nothing useful to do with it, i just wanted to learn it.
Fast forward to now, I just bought an Arduino Demunlovve (or however its spelled) and an LCD\Keypad Shield from DF Robot. I figure that i shouldn't waste time with the picaxe when trying to learn, since arduino is so well documented with libraries and stuffs and of course this forum full of people willing to help. I have a background in Mechanical Engineering with some knowledge of basic circuits. I REALLY want to learn this stuff so I can bring some of my dumb ideas to life. I need an end goal, so I came up with (drumroll..) THE AUTOMATIC TIRE INFLATOR!!!
I figure i will learn A LOT if I can complete this /simple/ project.
What I plan on using:
Arduino Demunlofevaerefassferfoh (gah)
LCD\Keypad Shield from DF Robot
Freescale Semiconductor MPX5500 Pressure sensor - should be good enough for my car tire
cheapie air compressor from harbor freight - not exactly what I have, but you get the idea
IRF510 MOSFET and protection diode - this will switch the compressor on and off.
Goal:
I have a tire that has a slow leak, and I have to inflate it every couple days. Instead of spending money on a new tire, I spent it on an Arduino. My girlfriend says i'm an idiot (she's heard this before... "Yeah! I'm gonna do it!").
I want to be able to plug in the pump. the arduino gets power from the 12v cigarette lighter, and turns on. The lcd flashes a quick "hello", clears the screen, and brings you to this screen:
|Tire PSI: xx|
|Set PSI: xx|
The 'xx' next to Tire PSI would be the actual psi from the tire, as read from the pressure sensor. **I assume that I would use the "map" command in the sketch to translate a voltage reading to a pressure, which i would then set as a variable and print it to the LCD. Correct?
The 'xx' next to Set PSI would default to 32, which is the pressure my crappy tire is supposed to be at. However, I would like to be able to hit the up\down buttons on the shield to change this set PSI. I have no idea how i'm going to do this yet. I'm going to try to go through the example in LCD4Bit_mod library to figure out how a keypress can change a variable that is stored, and then print this variable and use it as the target pressure. I may need help on this, but don't tell me right away... gimmie a chance to at least try... ![]()
After SetPSI is set by me, I would then hit the "select" button on the keypad, and the arduino would realize that TirePSI<SetPSI and would set the output pin to mosfet to HIGH, and the pump would begin filling the tire.
When the Pump gets up to SetPSI, it would shut off the pump, clear the screen, and print "YAY!" or something like that. A quick hit of the reset button would reset the prog to allow me to fill another tire.
Things to add in the future:
-a solenoid valve to release pressure, if the tire is over inflated. this would be useful at a drag strip, when i want to lower PSI
-possibly a radio to get rid of the pressure sensor, and use the cars TPMS sensor built into the wheel
-a quick "how-to" that would flash on the LCD in the beginning so someone else would know how to use it
Where i'm at right now....
I have the LCD4Bit_mod library, but after looking at the examples I got confused. I didn't understand what was going on. Then I looked at the examples in the LiquidCrystal Library, and that stuff made sense, mainly because there were lots of examples that were well //commented, and I could look up the syntax of the commands on arduino.cc website.
I looked at the circuit diagram for my LCD\Keypad Shield, and realized that all i had to do was change the following line, and then all the LiquidCrystal.h examples would work with my shield:
from:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
to:
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
So, why would I use the LCD4Bit_mod library, if I could use this library? Since the keypad buttons use an AnalogInput pin and a voltage divider, can't I just copy and paste the bit of code from the LCD4Bit_mod example for recognizing key input, and continue using the LiquidCrystal library?
After A bit of fiddling, I managed to figure this out:
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// turn on the cursor:
lcd.cursor();
}
void loop() {
delay(500);
lcd.setCursor(0,0);
lcd.print("Tire PSI:");
lcd.setCursor(0,1);
lcd.print("Set PSI:");
delay(500);
}
Now, I need to figure out how to display the actual tire pressure, and put it on the right side of the LCD screen. This is what i'm thinking, tell me if i'm wrong:
read voltage from sensor. map it to pressure, and put that number into a variable. print that variable to the screen
I also need to figure out how to default display '32' as the Set PSI, and use keypad to change that number. This is what i'm thinking, tell me if i'm an idiot:
#define Pump SomeUnusedPin //pin the mosfet is on
int SetPSI = 32 //default psi setting
if (up button is pressed), then SetPSI ++
lcd.print SetPSI
If (down button is pressed), then SetPSI --
lcd.print SetPSI
then...
If (select button is pressed), then Pump = HIGH
If (psi = SetPSI), then Pump = LOW
Am I on track here, or am I totally out of the "void loop()"?!?
LOL, i'm totally loving my new geek humor...
Another thought: I'm still trying to figure out how to justify my pressure values to the right side of the LCD. I suppose I can:
lcd.setCursor(14,0)
lcd.print (TirePSI)
lcd.setCursor(14,1)
lcd.print (SetPSI)
but if for some reason there was a triple digit PSI number, the third digit would be off the screen. some way to automatically justify it would be nice...
YET another thought:
If i remember correctly, Maybe a mosfet would not be good to use. I think these things have a duty cycle and will not like being constantly on for a long period of time, and I should use a relay instead. I'm not sure, i'll read up on this.
ANY AND ALL HELP WOULD BE GREAT. I prefer to try and figure this out on my own, but please let me know if i'm way off or help me answer any questions i may come up with. I plan on updating this thread every step of the way.
THANK YOU!!!