File size: 649 Bytes
2b71e80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
"""skyelahAndriy.195

Automatically generated by Colab.

Original file is located at
    https://colab.research.google.com/drive/1cStg9EvSGG9MQ3ObrBKuJb-7MTSfKD3f
"""

import RPi.GPIO as GPIO
import ADC0834
from time import sleep
dt=.1
redPin=23
DC=0
GPIO.setmode(GPIO.BCM)
ADC0834.setup()
GPIO.setup(redPin,GPIO.OUT)
myPWM=GPIO.PWM(redPin,1000)
myPWM=start(DC)
try:
  while True:
    potVal=ADC0834.getResult(0)
    DC=(100/255)*potVal
    if DC>99:
      DC=99
      myPWM.ChangeDutycycle(DC)
      print(potVal, DC)
      sleep(dt)
except KeyboardInterrupt:
  myPWM.stop()
  GPIO.cleanup()
  print('GPIO Ready to Perform')