Need some help in tweaking the 'first smartapp'

Hi, I’m trying to tweak the ‘The first smartapp’. What I need is have it on turn on a timed light on sunny days (with motion),but leave the light on (again on motion) when dark or cloudy.
I have an area that needs a little more light in the day time. There is a unlighted section next to this area. Right now I keep the light on at all times.

Here’s what I have tried. I’m not a programmer and it looks like there are too many things I don’t know. I would appreciate some ones help in getting this to work.

preferences {
section(“Turn on this light:”) {
input “theswitch”, “capability.switch”, required: true
section(“Choose your motion detector:”) {
input “themotion”, “capability.motionSensor”, required: true, title: “Where?”
section(“Turn off when there’s been no movement for”) {
input “minutes”, “number”, required: true, title: “Minutes?”
section(“Choose your light sensor:”) {
input “lightSensor”, “capability.illuminanceMeasurement”
section(“What LUX level is considered too ndark?”) {
input “luxLevel”, “number”, required: true
def installed() {
log.debug "Installed with settings: ${settings}"
def updated() {
log.debug "Updated with settings: ${settings}"
def initialize() {
subscribe(themotion, “”, motionDetectedHandler)
subscribe(themotion, “motion.inactive”, motionStoppedHandler)
subscribe(lightSensor, “illuminance”, illuminanceHandler)
def motionDetectedHandler(evt) {
log.debug "motionDetectedHandler called: $evt"
def motionStoppedHandler(evt) {
log.debug "motionStoppedHandler called: $evt"
runIn(60 * minutes, checkMotion)
def checkMotion() {
log.debug "Im checking Motion Now - scheduled method"
def motionState = themotion.currentState(“motion”)
def darkness = settings.luxLevel.toInteger()
log.debug "Lux level for darkness is $darkness"
def lightSensorState = lightSensor.currentilluminance
log.debug "CurrBright = $lightSensorState"
if (motionState.value == “inactive”) {
def elapsed = now() - // get the time elapsed between now and when the motion reported inactive
log.debug "elapsed is $elapsed"
def threshold = 1000 * 60 * minutes // elapsed time is in milliseconds, so the threshold must be converted to milliseconds too
log.debug "threshold is $threshold"
if (elapsed >= threshold && darkness <= CurrBright) {
log.debug "Motion has stayed inactive long enough since last check ($elapsed ms): turning switch off"
} else {
log.debug “Motion has not stayed inactive long enough since last check ($elapsed ms): doing nothing”
} else {
// Motion active; just log it and do nothing
log.debug “Motion is active, do nothing and wait for inactive”

If you don’t plan on developing SmartApps and you’re just trying to get this specific automation to work, use the SmartApp CoRE instead.

It’s a rules engine that allows you to do pretty much anything imaginable without having to write any code.