Ok, another experiment...
what i want to do is change intensity of a LED (why? ... boh!)
Looking on the web this thing seems to be called "Dim a LED"
what i need:
Configuration of this project is pretty simple. All you must to do is to connect ground pin from Raspberry Pi to negative track on breadboard (the blue track) and then connect pin 23 from Raspberry Pi to the track in whitch there is positive pin of our LED (now i know it's name: ANODE for positive pin and CATHODE for the negative pin ... mhhh wonderfull...).
Then we need to connect cathode (MWAHHAHA i hope not to forget this name) pin of our LED to negaitive track (the blue track of breadboard) with a resistor.
This is the schema
from schema to reality we have this:
well done... now open youtube and listen to this: https://www.youtube.com/watch?v=dJjL2waEG0Q
ok, now it's time to see the code:
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.OUT)
# con PWM dovrei assegnare la porta 23
red = GPIO.PWM(23, 100)
# il led red parte con una intensita di 100
red.start(100)
pause_time = 0.02
try:
while True:
# diminuisco l'intensita
for i in range(0,101):
red.ChangeDutyCycle(100 - i)
sleresistor ep(pause_time)
# aumento l'intensita
for i in range(0,101):
red.ChangeDutyCycle(0 + i)
sleep(pause_time)
except KeyboardInterrupt:
red.stop()
GPIO.cleanup()
let's take a look more in deep:
what means this line?? --> red = GPIO.PWM(23, 100)
or , what is GPO.PWM ??
Looking PWM on the web, PWM is "Pulse-width Modulation" (see wikipedia) : is a technique to encode a message into a pulsing signal.
With red = GPIO.PWM(23, 100) we are telling that red is a PWM connected to pin 23 with 100 of intensity (is correct?? boh).
With red.ChangeDutyCycle(100 - i) we are reducing light intensity and with red.ChangeDutyCycle(0 + i) we are increasing light intensity.
I hope to provide one day a better explanation :( .
Ok this is the result:
what i want to do is change intensity of a LED (why? ... boh!)
Looking on the web this thing seems to be called "Dim a LED"
what i need:
- one LED
- one resistor
- one glass of limoncello
Configuration of this project is pretty simple. All you must to do is to connect ground pin from Raspberry Pi to negative track on breadboard (the blue track) and then connect pin 23 from Raspberry Pi to the track in whitch there is positive pin of our LED (now i know it's name: ANODE for positive pin and CATHODE for the negative pin ... mhhh wonderfull...).
Then we need to connect cathode (MWAHHAHA i hope not to forget this name) pin of our LED to negaitive track (the blue track of breadboard) with a resistor.
This is the schema
from schema to reality we have this:
well done... now open youtube and listen to this: https://www.youtube.com/watch?v=dJjL2waEG0Q
ok, now it's time to see the code:
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.OUT)
# con PWM dovrei assegnare la porta 23
red = GPIO.PWM(23, 100)
# il led red parte con una intensita di 100
red.start(100)
pause_time = 0.02
try:
while True:
# diminuisco l'intensita
for i in range(0,101):
red.ChangeDutyCycle(100 - i)
sleresistor ep(pause_time)
# aumento l'intensita
for i in range(0,101):
red.ChangeDutyCycle(0 + i)
sleep(pause_time)
except KeyboardInterrupt:
red.stop()
GPIO.cleanup()
let's take a look more in deep:
what means this line?? --> red = GPIO.PWM(23, 100)
or , what is GPO.PWM ??
Looking PWM on the web, PWM is "Pulse-width Modulation" (see wikipedia) : is a technique to encode a message into a pulsing signal.
With red = GPIO.PWM(23, 100) we are telling that red is a PWM connected to pin 23 with 100 of intensity (is correct?? boh).
With red.ChangeDutyCycle(100 - i) we are reducing light intensity and with red.ChangeDutyCycle(0 + i) we are increasing light intensity.
I hope to provide one day a better explanation :( .
Ok this is the result:
Commenti
Posta un commento