Hello everyone

I was trying to create an app for my x-fi2, but I can't make it working properly, it just doesn't turn... here I post the code, maybe you know where I'm wrong
Code:
h = screen.height()
w = screen.width()
black = color.new(0,0,0)
red = color.new(255,0,0)
screen.fillrect(0,0,w,h,black)
txtsize = text.size(30)
txtcolor = text.color(red)
string = "Hello, World!"
text.draw(0,80,string,"center",w)
screen.update()
text.size(txtsize)
text.color(txtcolor)
screen.update()
--Accendo l'accelerometro
accInit = accelerometer.open();
print(accInit); --Stampo il valore, se è 0 l'accelerometro è acceso
oldDir = accelerometer.getdata("orientation");
while 1 do
--controllo la posizione dell'accelerometro
dir = accelerometer.getdata("orientation");
if dir ~= oldDir then
if dir == 1 then
screen.orientation(0);
elseif dir == 2 then
screen.orientation(1);
elseif dir == 3 then
screen.orientation(0);
elseif dir == 4 then
screen.orientation(1);
end
oldDir = dir;
green = color.new(124,252,0)
txtsize = text.size(30)
txtcolor = text.color(green)
text.draw(0,80,string,"center",w)
screen.update()
text.size(txtsize)
text.color(txtcolor)
screen.update()
end
if control.read()==1 then
if control.isButton()==1 then
if button.click()==1 then
if accInit==0 then
accelerometer.close();
end
break
end
elseif control.isTouch()==1 then
if accInit==0 then
accelerometer.close();
end
break
end
else
os.sleep(10)
end
end
it's almost all copied from the tutorial, but it doesn't turn...either it doesn't become green...where I'm doing it wrong?