New to any type of programming, I was wondering if anyone can tell me why I cant get the second half of this code to run (lines 14-23). Any help would be appreciated and if anyone has any suggestions to the best place to learn more.
Thanks!
Help with code. Adafruit Trinket MO
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- JKracht
- Posts: 4
- Joined: Mon Sep 27, 2021 4:25 pm
Help with code. Adafruit Trinket MO
- Attachments
-
- Light Circuit.py
- (437 Bytes) Downloaded 11 times
- adafruit_support_carter
- Posts: 29360
- Joined: Tue Nov 29, 2016 2:45 pm
Re: Help with code. Adafruit Trinket MO
You have two infinite loops. Only the first one is being run:
Nothing after that is ever reached.
Code: Select all
while True:
led.value = True
time.sleep(2.0)
led.value = False
time.sleep()
- JKracht
- Posts: 4
- Joined: Mon Sep 27, 2021 4:25 pm
Re: Help with code. Adafruit Trinket MO
How do I stop the infinite loop?
- adafruit_support_carter
- Posts: 29360
- Joined: Tue Nov 29, 2016 2:45 pm
Re: Help with code. Adafruit Trinket MO
You can stop the entire code from running by using <CTRL><C>, but that's probably not what you are after.
What are you trying to get the code to do?
What are you trying to get the code to do?
- JKracht
- Posts: 4
- Joined: Mon Sep 27, 2021 4:25 pm
Re: Help with code. Adafruit Trinket MO
I'm trying to get the code to run function 1
while True:
led.value = True
time.sleep(2.0)
led.value = False
time.sleep()
then stop and then just run the second part, after the first one has shut off
while True:
led.value = False
time.sleep(3.0)
led.value = True
time.sleep(1.0)
led.value = False
time.sleep()
basically to just control a relay and shut off then control a second one and shut off.
while True:
led.value = True
time.sleep(2.0)
led.value = False
time.sleep()
then stop and then just run the second part, after the first one has shut off
while True:
led.value = False
time.sleep(3.0)
led.value = True
time.sleep(1.0)
led.value = False
time.sleep()
basically to just control a relay and shut off then control a second one and shut off.
- adafruit_support_carter
- Posts: 29360
- Joined: Tue Nov 29, 2016 2:45 pm
Re: Help with code. Adafruit Trinket MO
You want those actions to happen only once?
- adafruit_support_carter
- Posts: 29360
- Joined: Tue Nov 29, 2016 2:45 pm
Re: Help with code. Adafruit Trinket MO
Then the loops probably are not needed.
What determines when the first one has shut off? Do you need to wait for something before the second part is run? Or can the second part run immediately after the first?then stop and then just run the second part, after the first one has shut off
Please be positive and constructive with your questions and comments.