Hand Held PC
Hi all..
This is one of my creations made out of boredom, it consists of:
- Vtech V Smile (case)
- 5.6" TFT LCD
- Dell Thin Client PC FX130 (1Ghz VIA,1 GB ram, 1GB SSD, Win XP nlited)
- Arduino Mini Clone
- 12V Lithium Rechargeable Battery
- Some putty
- Hot Knife
- Wrist action (sanding!!)
- Broken PS3 pad
- Hot Glue
Get Your Stuff!
I got the Vsmile off Amazon for around £20, the Arduino set me back £6 and got it off ebay along with the thin client PC for £20. The screen cost me around £30 and the 12V battery £10 and got them off ebay also. I had a faulty PS3 pad which I used for the buttons and the analog stick.
Rip Everything Apart, Cut, Mold, Stick and Sand!
I had an old PSP screen lying around so I used this as a template to cut the screen out. I cut the buttons on analog stick out of the PS3 pad out and used the excess plastic to fill in the gaps on the Vtech shell..
Tweaks & Testing
The Ardunio clone didn't have any boot loader so I had to get the old trusty GQ4-X programmer and flashed the clone though the ICSP port.
The Arduino micro clone I had didn't have the functionality of changing the usb function other than a serial port emulation so I had to write two programs instead of one.
The Arduino program basically captures the buttons and analog stick and sends the data via serial
Analog X->A0
AnalogY->A1
Other buttons D0 <-> D8
Here's the code for the Micro
// These constants won't change. They're used to give names<br>// to the pins used: const int analogInPinY = A0; // Analog input pin that the potentiometer is attached to const int analogInPinX = A1; // Analog input pin that the potentiometer is attached to int outputValueY = 0; // value output to the PWM (analog out) int outputValueX = 0; // value output to the PWM (analog out) int centreY = 0; //Callibrate int centreX = 0; //Callibrate int Ypos = 0; int TempY = 0; int NegY = 0; int Xpos = 0; int TempX = 0; int NegX = 0; // constants won't change. They're used here to // set pin numbers: const int buttonup = 2; // the number of the pushbutton pin const int buttonright = 3; // the number of the pushbutton pin const int buttonleft = 4; // the number of the pushbutton pin const int buttondown = 5; // the number of the pushbutton pin const int buttonDiamond = 9; // the number of the pushbutton pin const int buttonTriangle = 8; // the number of the pushbutton pin const int buttonRed = 7; // the number of the pushbutton pin const int buttonYellow = 6; const int buttonAnalog = 10; const int buttonMode = 11; const int ledPin = 13; // the number of the LED pin const int led2Pin = A2; // variables will change: int dirState = 0; // variable for reading the pushbutton status int buttonState = 0; // variable for reading the pushbutton status int CTX; int AnalogNegs = 0; int PadMode; int Fader = 0; int FaderDir = 0; void setup() { Serial.begin(19200); // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); pinMode(led2Pin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonup, INPUT_PULLUP); pinMode(buttondown, INPUT_PULLUP); pinMode(buttonleft, INPUT_PULLUP); pinMode(buttonright, INPUT_PULLUP); pinMode(buttonTriangle, INPUT_PULLUP); pinMode(buttonDiamond, INPUT_PULLUP); pinMode(buttonYellow, INPUT_PULLUP); pinMode(buttonRed, INPUT_PULLUP); pinMode(buttonAnalog, INPUT_PULLUP); pinMode(buttonMode, INPUT_PULLUP); CTX = analogRead(analogInPinX); centreY = map(analogRead(analogInPinY), 0, 1023, 0, 254); centreX = map(analogRead(analogInPinX), 0, 1023, 0, 254); Callib;} void Callib() { //TRY!! Callibrate Centre centreY = map(analogRead(analogInPinY), 0, 1023, 0, 254); centreX = map(analogRead(analogInPinX), 0, 1023, 0, 254); } void loop(){ // read the state of the pushbutton value: outputValueY = map(analogRead(analogInPinY), 0, 1023, 0, 254); outputValueX = map(analogRead(analogInPinX), 0, 1023, 0, 254); Ypos = 0; NegY = 0; TempY = (outputValueY - centreY); if (TempY > 5 || TempY < -5) { digitalWrite(ledPin, HIGH); NegY = TempY < -5 ; Ypos = TempY & 254; }; Xpos = 0; NegX = 0; TempX = (outputValueX - centreX); if (TempX > 5 || TempX < -5) { digitalWrite(ledPin, HIGH); NegX = TempX < -5 ; // if (TempX < -83){TempX = -84;} // if (TempX > 83){TempX = 84;} Xpos = TempX & 254; }; // Serial.println(TempX); //Serial.println(Xpos); dirState = 0; dirState |= (digitalRead(buttonup) ^ 1) << 0; dirState |= (digitalRead(buttondown) ^ 1) << 1; dirState |= (digitalRead(buttonleft) ^ 1) << 2; dirState |= (digitalRead(buttonright) ^ 1) << 3; buttonState = 0; buttonState |= (digitalRead(buttonTriangle) ^ 1) << 0; buttonState |= (digitalRead(buttonDiamond) ^ 1) << 1; buttonState |= (digitalRead(buttonYellow) ^ 1) << 2; buttonState |= (digitalRead(buttonRed) ^ 1) << 3; buttonState |= (digitalRead(buttonAnalog) ^ 1) << 4; int d = (digitalRead(buttonMode) ^ 1); if (PadMode > 0) { //delay(30); digitalWrite(led2Pin, HIGH);} else{ digitalWrite(led2Pin, LOW); } //if (PadMode = 0) {analogWrite(A2, 0);} if (d > 0 ){ PadMode = (PadMode ^ 1); // // PadMode = 1; // digitalWrite(A2, HIGH);} //return;} while ((digitalRead(buttonMode) ^ 1) > 0) { } delay(3);} buttonState |= PadMode << 5; AnalogNegs = NegX << 0; AnalogNegs |= NegY << 2; Serial.write(0xFF); //sync Serial.write(dirState); Serial.write(buttonState); Serial.write(AnalogNegs); Serial.write(Xpos); Serial.write(Ypos); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (dirState > 0 || buttonState > 0) { // turn LED on: digitalWrite(ledPin, HIGH); //analogWrite(A2, 20); } else { // turn LED off: digitalWrite(ledPin, LOW); Callib; // delay(3); } delay(2); }
I've used a sync byte to synchronize the serial data to the FreeBasic program. I also added an LED that sits in the centre button which is used as a 'Mode' button to give another layer of control.
The FreeBasic program converts the serial data from the Arduino into to keyboard keystrokes, it's run upon start-up of windows as a background task.
Thanks to Ben Heck for the inspiration!!