Try experimenting with 'Simple Brightness Applet' in your do loop to see what value it set the screen brightness to, then if those value appear when you 'cat /sys/class/backlight/acx565akm/brightness' substitute you own values to suit you. Run you script in XTerm to see whats going on first. Keep us updated.