August 14, 2017

Changing the brightness on an LED

     The next lesson I tackled was Raspberry Pi LESSON 27: Analog Voltages Using GPIO PWM in Python. I don't know exactly what's going on here but I did it anyway.


     Mr. McWhorter didn't explain everything going on here but I'm sure I could Wiki it. Is there a Wiki for electronics? I might have to put down the RPi and find out. I'm sure I'll find out eventually in my studies for college. He might have gone over these concepts on his videos for the Arduino but I haven't watched those as I don't have one.


     In this lesson we wrote some code in Python to change the brightness of the LED. The program asked "How bright do you want the LED? (1-6)" and it would change the brightness according to the input. The input was then converted to x and 2^x was solved and used as the duty cycle variable. The question only works from 1 to about 6.6 because above that the variable goes beyond 100, which is our maximum frequency in hertz, set early in the program. It went as planned for me. These are the pictures of my LED at different brightness.



     In this video, Mr. McWhorter has to do a lot of debugging of his code. It might seem a bit tedious to experienced coders and makers. I find it useful to see his thought processes when he makes mistakes. It helps me learn what can go wrong in something I have little recent experience in. Now I just have to figure out how to stop his loops in the code. I'm sure I will eventually.

No comments:

Post a Comment

Thanks for leaving a comment! I'll get back to you ASAP but I've got a busy life