Question

Write a program in CircuitPython to run on the FM4E that will turn on the heater...

Write a program in CircuitPython

to run on the FM4E that will turn on the heater for one minute if the button is pressed. The LED should be turned on when the heater is on, and it should go off when the heater turns off after one minute. Make sure your code has comments.

0 0
Add a comment Improve this question Transcribed image text
Answer #1


import time
import board
from digitalio import DigitalInOut, Direction, Pull

led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT

# For Gemma M0, Trinket M0, Metro M0 Express, ItsyBitsy M0 Express, Itsy M4 Express
switch = DigitalInOut(board.D2)
# switch = DigitalInOut(board.D5) # For Feather M0 Express, Feather M4 Express
# switch = DigitalInOut(board.D7) # For Circuit Playground Express
switch.direction = Direction.INPUT
switch.pull = Pull.UP

while True:
# We could also do "led.value = not switch.value"!
if switch.value:
led.value = False
else:
led.value = True

time.sleep(0.01) # debounce delay

Add a comment
Know the answer?
Add Answer to:
Write a program in CircuitPython to run on the FM4E that will turn on the heater...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT