How to script brightness turning down and up?
Provided the necessary accessibility privileges are granted that permits UI scripting, this script programmatically adjusts the brightness of your screen by way of System Preferences:

tell application "System Preferences"
    set current pane to pane id "com.apple.preference.displays"
    reveal anchor "displaysDisplayTab" of current pane
end tell

tell application "System Events" to tell ¬
    process "System Preferences" to tell ¬
    window 1 to tell ¬
    tab groups to tell ¬
    groups to tell ¬
    sliders to set its value to 0.5 -- 0.0 to 1.0

quit application "System Preferences"


You can set that value you see to any decimal value between 0.0 (minimum brightness, display off) and 1.0 (maximum brightness).