* Created a file for "Basics of Raspberry Pi Stuffs" The code contains two parts: First part is simply blinking led (Blink time can be set by time.sleep(x) x for the number of seconds) Second part is for pwm control for led brightness * Update RaspberryPiBasics.py * reformatted two 2 space indention with title corr.
		
			
				
	
	
		
			39 lines
		
	
	
		
			700 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			700 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
---
 | 
						|
title: Rasberry PI Basics
 | 
						|
---
 | 
						|
 | 
						|
## Rasberry PI Basics Example
 | 
						|
```python
 | 
						|
## CODE THAT MAKES AN LED GLOW FOR 2 SECONDS
 | 
						|
import time
 | 
						|
import RPi.GPIO as GPIO
 | 
						|
while True:
 | 
						|
  GPIO.output(2, GPIO.HIGH
 | 
						|
  time.sleep(1)
 | 
						|
  GPIO.output(2, GPIO.LOW) 
 | 
						|
  time.sleep(1)
 | 
						|
 | 
						|
## CODE FOR PWM CONTROL OF LED BRIGHNTESS
 | 
						|
import RPi.GPIO as GPIO from time
 | 
						|
import sleep led_pin = 2
 | 
						|
 | 
						|
GPIO.setmode(GPIO.BCM)
 | 
						|
GPIO.setup(led_pin, GPIO.OUT)
 | 
						|
 | 
						|
pwm = GPIO.PWM(led_pin, 100)
 | 
						|
pwm.start(0)
 | 
						|
 | 
						|
try:
 | 
						|
  while True:
 | 
						|
    for x in range(100):
 | 
						|
      pwm.ChangeDutyCycle(x)
 | 
						|
      sleep(0.01)
 | 
						|
    for x in range(100, 0, -1):
 | 
						|
      pwm.ChangeDutyCycle(x)
 | 
						|
      sleep(0.01)
 | 
						|
 | 
						|
except KeyboardInterrupt:
 | 
						|
  pwm.stop()
 | 
						|
  GPIO.cleanup()
 | 
						|
```              
 |