From 8d31394caebce0d55a2a12e835751a8aae9c0950 Mon Sep 17 00:00:00 2001 From: Suhayl <838119509@qq.com> Date: Thu, 27 Jun 2019 09:59:54 +0800 Subject: [PATCH] remove file. remove file. rename. --- .../Python_Code/08.1.1_SoftLight/SoftLight.py | 53 ------------------- .../Python_Code/08.1.1_Softlight/Softlight.py | 53 ------------------- 2 files changed, 106 deletions(-) delete mode 100644 Code/Python_Code/08.1.1_SoftLight/SoftLight.py delete mode 100644 Code/Python_Code/08.1.1_Softlight/Softlight.py diff --git a/Code/Python_Code/08.1.1_SoftLight/SoftLight.py b/Code/Python_Code/08.1.1_SoftLight/SoftLight.py deleted file mode 100644 index 7a3cd88..0000000 --- a/Code/Python_Code/08.1.1_SoftLight/SoftLight.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python3 -############################################################################# -# Filename : Softlight.py -# Description : Potentiometer control LED -# Author : freenove -# modification: 2018/08/02 -######################################################################## -import RPi.GPIO as GPIO -import smbus -import time - -address = 0x48 -bus=smbus.SMBus(1) -cmd=0x40 -ledPin = 11 - -def analogRead(chn): - value = bus.read_byte_data(address,cmd+chn) - return value - -def analogWrite(value): - bus.write_byte_data(address,cmd,value) - -def setup(): - global p - GPIO.setmode(GPIO.BOARD) - GPIO.setup(ledPin,GPIO.OUT) - GPIO.output(ledPin,GPIO.LOW) - - p = GPIO.PWM(ledPin,1000) - p.start(0) - -def loop(): - while True: - value = analogRead(0) #read A0 pin - p.ChangeDutyCycle(value*100/255) #Convert ADC value to duty cycle of PWM - voltage = value / 255.0 * 3.3 #calculate voltage - print ('ADC Value : %d, Voltage : %.2f'%(value,voltage)) - time.sleep(0.01) - -def destroy(): - bus.close() - GPIO.cleanup() - -if __name__ == '__main__': - print ('Program is starting ... ') - setup() - try: - loop() - except KeyboardInterrupt: - destroy() - - diff --git a/Code/Python_Code/08.1.1_Softlight/Softlight.py b/Code/Python_Code/08.1.1_Softlight/Softlight.py deleted file mode 100644 index 7a3cd88..0000000 --- a/Code/Python_Code/08.1.1_Softlight/Softlight.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python3 -############################################################################# -# Filename : Softlight.py -# Description : Potentiometer control LED -# Author : freenove -# modification: 2018/08/02 -######################################################################## -import RPi.GPIO as GPIO -import smbus -import time - -address = 0x48 -bus=smbus.SMBus(1) -cmd=0x40 -ledPin = 11 - -def analogRead(chn): - value = bus.read_byte_data(address,cmd+chn) - return value - -def analogWrite(value): - bus.write_byte_data(address,cmd,value) - -def setup(): - global p - GPIO.setmode(GPIO.BOARD) - GPIO.setup(ledPin,GPIO.OUT) - GPIO.output(ledPin,GPIO.LOW) - - p = GPIO.PWM(ledPin,1000) - p.start(0) - -def loop(): - while True: - value = analogRead(0) #read A0 pin - p.ChangeDutyCycle(value*100/255) #Convert ADC value to duty cycle of PWM - voltage = value / 255.0 * 3.3 #calculate voltage - print ('ADC Value : %d, Voltage : %.2f'%(value,voltage)) - time.sleep(0.01) - -def destroy(): - bus.close() - GPIO.cleanup() - -if __name__ == '__main__': - print ('Program is starting ... ') - setup() - try: - loop() - except KeyboardInterrupt: - destroy() - -