Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PSP™ Tilt Sensor

Status
Not open for further replies.

SuperAng

New Member
I'm having a bit of unease with this project I'm working on. First off, I don't know if anyone knows Lua, but this is my program. It's fairly basic, but afterall, it only needs to read data from an accelerometer.

RED = Color.new(255,0,0)
WHITE = Color.new(255,255,255)
ORANGE = Color.new(255,102,0)
BLUE = Color.new(0,153,255)

screen:clear()

PROPORTIONAL = Font.createProportional()
PROPORTIONAL:setPixelSizes(0, 12)

BUF = ""
TEXT = ""
N1 = 0
N2 = 0
ORG1 = 0
ORG2 = 0
STATUS = "NOT INITIALIZED"
VERSION = "0.00.00:01 BETA"
A=0

while true do
screen:clear()

screen:fontPrint(PROPORTIONAL,5,10,"Device: "..STATUS,BLUE)
screen:fontPrint(PROPORTIONAL,5,30,"[START]: Exit",ORANGE)
screen:fontPrint(PROPORTIONAL,5,43,"[SQUARE]: Initialize device",ORANGE)
screen:fontPrint(PROPORTIONAL,10,56,"> [R TRIGGER]: Begin testing",RED)
screen:fontPrint(PROPORTIONAL,5,187,"PSP Tilt Sensor",WHITE)
screen:fontPrint(PROPORTIONAL,5,200,VERSION,WHITE)
screen:fontPrint(PROPORTIONAL,5,213,"SuperAng",BLUE)
screen:fontPrint(PROPORTIONAL,5,239,"http://PSPLua.com/SuperAng",ORANGE)
screen:fontPrint(PROPORTIONAL,5,252,"July 9, 2007",WHITE)

PAD = Controls.read()
if PAD:start()
then
break
end

if PAD:triangle()
then
ORG1 = N1 ORG2 = N2
end

if PAD:square()
then
A=1
System.sioInit(2400)
System.sleep(1000)
STATUS = "INITIALIZED . . . READY"
end

if A == 1
then

if PAD:r()
then
BUF = System.sioRead()
for i = 1,string.len(BUF) do
CH = string.sub(BUF,i,i)

if CH == "\r" or CH == "\n"
then

if string.sub(TEXT,1,1) ~= ":"
then
TEXT = "" CH = ""
end

if string.len(TEXT)>6
then
N1=tonumber(string.sub(TEXT,2,4))
N2=tonumber(string.sub(TEXT,5,7))

if N1 ~= nil and N2 ~= nil
then
X = N1-ORG1
Y = N2-ORG2
screen:clear()
screen:fontPrint(PROPORTIONAL,5,70,"X: "..X,WHITE)
screen:fontPrint(PROPORTIONAL,5,83,"Y: "..Y,WHITE)

if X<100 and X>-100 and Y<100 and Y>-100
then
screen:drawLine(X+344-5,-Y+136,X+344+5,-Y+136,WHITE)
screen:drawLine(X+344,-Y+136-5,X+344,-Y+136+5,WHITE)
end

screen.waitVblankStart()
screen:flip()

end

TEXT = ""
CH = ""

end
end

TEXT = TEXT..CH

end

end

end

screen:drawLine(244,36,444,36,WHITE)
screen:drawLine(244,236,444,236,WHITE)
screen:drawLine(244,36,244,236,WHITE)
screen:drawLine(444,36,444,236,WHITE)

screen.flip()
screen.waitVblankStart()
end

My first thought was that I would need some sort of external driver to read the serial port on the PSP (remote control for the headphones). But then I realized that it's being done within the program. But I'm confused as to how the program reads the accelerometer. Is it in turn reading the microcontroller? I don't know how the accelerometer sends data to the microcontroller, so I'm a bit lost. Anyway, take a look at the schematic and let me know if this is at all possible, or if it's just a hoax. Thanks.

(Schematic for PSP tilt sensor).

I have found a release of binaries for the PIC16F873 microcontroller. I don't know what to do with it, so maybe you guys can help. It's on www.kako.com (translate with Google.com first so you can read it), and look for "gravity sensor".
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top