
from letmecreate.core.common import MIKROBUS_1
from letmecreate.core import led
from letmecreate.click import motion


def flash_leds(arg):
    # Only flash LED's when motion starts getting detected.
    if arg != 1:
        return

    for i in range(10):
        led.switch_on(led.ALL_LEDS)
        sleep(0.1)
        led.switch_off(led.ALL_LEDS)
        sleep(0.1)


led.init()
motion.enable(MIKROBUS_1)
motion.attach_callback(MIKROBUS_1, flash_leds)

print("LED's will flash when Motion Click detects a movement.\n")
print("Press Ctrl+C to quit.\n")


while True:
    pass


from letmecreate.core.common import MIKROBUS_1
from letmecreate.core import led
from letmecreate.click import motion
from time import sleep


def flash_leds(arg):
    # Only flash LED's when motion starts getting detected.
    if arg != 1:
        return

    for i in range(10):
        led.switch_on(led.ALL_LEDS)
        sleep(0.1)
        led.switch_off(led.ALL_LEDS)
        sleep(0.1)


led.init()
motion.enable(MIKROBUS_1)
motion.attach_callback(MIKROBUS_1, flash_leds)

print("LED's will flash when Motion Click detects a movement.\n")
print("Press Ctrl+C to quit.\n")


while True:
    pass

Add missing import for sleep
motion: Add missing import for sleep

Signed-off-by: Francois Berder <59eaf4bb0211c66c3d7532da6d77ecf42a779d82@outlook.fr>

  
  from letmecreate.core.common import MIKROBUS_1
  from letmecreate.core import led
  from letmecreate.click import motion
+ from time import sleep
  
  
  def flash_leds(arg):
      # Only flash LED's when motion starts getting detected.
      if arg != 1:
          return
  
      for i in range(10):
          led.switch_on(led.ALL_LEDS)
          sleep(0.1)
          led.switch_off(led.ALL_LEDS)
          sleep(0.1)
  
  
  led.init()
  motion.enable(MIKROBUS_1)
  motion.attach_callback(MIKROBUS_1, flash_leds)
  
  print("LED's will flash when Motion Click detects a movement.\n")
  print("Press Ctrl+C to quit.\n")
  
  
  while True:
      pass
  
Add missing import for sleep
## Code Before:

from letmecreate.core.common import MIKROBUS_1
from letmecreate.core import led
from letmecreate.click import motion


def flash_leds(arg):
    # Only flash LED's when motion starts getting detected.
    if arg != 1:
        return

    for i in range(10):
        led.switch_on(led.ALL_LEDS)
        sleep(0.1)
        led.switch_off(led.ALL_LEDS)
        sleep(0.1)


led.init()
motion.enable(MIKROBUS_1)
motion.attach_callback(MIKROBUS_1, flash_leds)

print("LED's will flash when Motion Click detects a movement.\n")
print("Press Ctrl+C to quit.\n")


while True:
    pass

## Instruction:
Add missing import for sleep
## Code After:

from letmecreate.core.common import MIKROBUS_1
from letmecreate.core import led
from letmecreate.click import motion
from time import sleep


def flash_leds(arg):
    # Only flash LED's when motion starts getting detected.
    if arg != 1:
        return

    for i in range(10):
        led.switch_on(led.ALL_LEDS)
        sleep(0.1)
        led.switch_off(led.ALL_LEDS)
        sleep(0.1)


led.init()
motion.enable(MIKROBUS_1)
motion.attach_callback(MIKROBUS_1, flash_leds)

print("LED's will flash when Motion Click detects a movement.\n")
print("Press Ctrl+C to quit.\n")


while True:
    pass
