Question

Write small python program on turning something on and turning something off. About 10 lines. As ...

Write small python program on turning something on and turning something off.

About 10 lines. As long as it has GPIO in it

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

Codesnap:

import RPī.GP10 as GPIO #Here it is GP10 to import import Adafruit_GPIO.SPI as SPI import Adafruit MCP3008 CLK = 18 # Change

Coding:

import RPi.GPIO as GPIO #Here it is GPIO to import
import Adafruit_GPIO.SPI as SPI
import Adafruit_MCP3008
CLK = 18 # Change here values to then pins you are using
MISO = 20
MOSI = 21
CS = 8
mcp = Adafruit_MCP3008.MCP3008(clk=CLK, cs=CS, miso=MISO, mosi=MOSI)
GPIO.setmode(GPIO.BCM) #sets mode
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Button Pin
state = GPIO.input(22) #Get's input button
while True:
      if state == 1:
            break
      else:
          continue

Add a comment
Know the answer?
Add Answer to:
Write small python program on turning something on and turning something off. About 10 lines. As ...
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